title: Why use apparently meaningless do-while and if-else statements in macros?
body: <p>In many C/C++ macros I'm seeing the code of the macro wrapped in what seems like a meaningless <code>do while</code> loop.  Here are examples.</p>
  
  <pre><code>#define FOO(X) do { f(X); g(X); } while (0)
  #define FOO(X) if (1) { f(X); g(X); } else
  </code></pre>
  
  <p>I can't see what the <code>do while</code> is doing.  Why not just write this without it?</p>
  
  <pre><code>#define FOO(X) f(X); g(X)
  </code></pre>