title: Pros and Cons of Different macro function / inline methods in C
body: <p><a href="http://c-faq.com/cpp/multistmt.html" rel="noreferrer">According to the C FAQ</a>, there are basically 3 practical methods for "inlining" code in C:</p>
  
  <pre><code>#define MACRO(arg1, arg2) do { \
      /* declarations */ \
      stmt1;   \
      stmt2;   \
      /* ... */  \
      } while(0)    /* (no trailing ; ) */
  </code></pre>
  
  <p>or</p>
  
  <pre><code>#define FUNC(arg1, arg2) (expr1, expr2, expr3)
  </code></pre>
  
  <p>To clarify this one, the arguments are used in the expressions, and the comma operator returns the value of the last expression.</p>
  
  <p>or </p>
  
  <p>using the <code>inline</code> declaration which is supported as an <a href="http://www.greenend.org.uk/rjk/2003/03/inline.html" rel="noreferrer">extension to gcc and in the c99 standard</a>.</p>
  
  <p>The <code>do { ... } while (0)</code> method is widely used in the Linux kernel, but I haven't encountered the other two methods very often if at all.</p>
  
  <p>I'm referring specifically to multi-statement "functions", not single statement ones like MAX or MIN.</p>
  
  <p>What are the pros and cons of each method, and why would you choose one over the other in various situations?</p>