title: Function call as argument to C macro
body: <p>First a little code:</p>
  
  <pre><code>int counter = 0;
  
  int get_counter() { return counter++; }
  
  #define EVEN_OR_ZERO(cc) ( (cc) % 2 == 0 ? (cc) : 0 )
  
  int next_even_or_zero = EVEN_OR_ZERO(get_counter());
  </code></pre>
  
  <p>This code might seem OK, but... Let's expand the macro:</p>
  
  <pre><code>int next_even_or_zero = get_counter() % 2 == 0 ? get_counter() : 0;
  </code></pre>
  
  <p>As you can see the macro will only return odd numbers - which is the opposite of what was expected (or desired).</p>
  
  <p>The question: Is there any way to get this work as intended with a macro? Or is a regular function the only way to go?</p>
  
  <pre><code>//This works as wanted
  int even_or_zero(int value) { return value % 2 == 0 ? value : 0; }
  </code></pre>