title: Conditional inside C macro?
body: <p>Is there any way to do this conditional at compile time instead of at runtime?</p>
  
  <p>"flag" will always be a constant. A() and B() are macros.</p>
  
  <pre><code>#define DEMO(flag, p) if (flag) A(p); else B(p)
  </code></pre>
  
  <p>Why do I want to do this? Because macro A may or may not exist, depending on the underlying hardware (macro A controls hardware on a microcontroller).</p>
  
  <p>If DEMO is called with "flag" <em>that evaluates to</em> false, it doesn't matter - it should compile. But if DEMO is called with "flag" <em>that evaluates to</em> true, I want to see a build error.</p>
  
  <p>ADDED:</p>
  
  <p>The intended use is like this:</p>
  
  <pre><code>DEMO(true, p);  // this should cause a build error
  DEMO(false, p); // this should compile OK
  DEMO(0, p); // should be OK
  DEMO(1 == 2, p); // should be OK
  DEMO(1 == 1, p); // should cause a build error
  </code></pre>
  
  <p>The passed parameter is always a constant, but not always the <em>same</em> constant.</p>