title: Error when defining a stringising macro with __VA_ARGS__
body: <p>I have been trying to implement a function macro in C that prepends "DEBUG: ", to the argument, and passes its arguments to printf:</p>
  
  <pre><code>#define DBG(format, ...) printf("DEBUG: " #format "\n", __VA_ARGS__)
  </code></pre>
  
  <p>This gives me this error in gcc:</p>
  
  <pre><code>src/include/debug.h:4:70: error: expected expression before ‘)’ token
  #define DBG(format, ...) printf("DEBUG: " #format "\n", __VA_ARGS__)
                                                                     ^
  </code></pre>
  
  <p>Supposedly, it should stringise format, and pass its variable arguments to printf, but so far I can't get past this error.</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>After giving up on stringising arguments, and double-hashing (<code>##</code>) <code>__VA_ARGS__</code> I now have this error:</p>
  
  <pre><code>src/lib/cmdlineutils.c: In function ‘version’:
  src/lib/cmdlineutils.c:56:17: warning: ISO C99 requires rest arguments to be used [enabled by default]
    DBG("version()");
  </code></pre>
  
  <p>Should I be placing a comma after the argument?</p>
  
  <pre><code>DBG("version()",);  // ?
  </code></pre>
  
  <p>For reference, DBG() now looks like this:</p>
  
  <pre><code>#define DBG(format, ...) printf("DEBUG: " format "\n", ##__VA_ARGS__)
  </code></pre>