title: Proper C preprocessor macro no-op
body: <p>For debug logging, I have often seen and used something like</p>
  
  <pre><code>#ifdef DEBUG
      #define DLOG(fmt, args...) printf("%s:%d "fmt,__FILE__,__LINE__,args)
  #else
      #define DLOG(fmt, args...)
  #endif
  </code></pre>
  
  <p>but in a number of places, I have seen the second <code>#define</code> replaced with</p>
  
  <pre><code>#define DLOG(fmt, args...) do {} while (0)
  </code></pre>
  
  <p>In particular, there's <a href="https://stackoverflow.com/a/1306690/291280">this answer</a>, and the comment on <a href="https://stackoverflow.com/a/1306683/291280">this other answer</a> to the same question suggests that the problem would be in a situation like</p>
  
  <pre><code>if (condition)
      DLOG("foo");
  </code></pre>
  
  <p>though my quick test suggests that the resulting semicolon on the line by itself will serve as the no-op statement inside the conditional.</p>
  
  <p>Is one or the other of <em>nothing</em> and <code>do {} while (0)</code> better?  If so, why?  Is there something else that's even better?</p>