title: How can I get the gcc preprocessor to check if an expression evaluates to a value or nothing?
body: <p>I'm using gcc (specifically avr-gcc).</p>
  
  <p>So this is my conundrum:</p>
  
  <p>Let's say I have these defined somewhere:</p>
  
  <pre><code>#define THING_0_A 0
  #define THING_0_B 1
  #define THING_1_A 0
  </code></pre>
  
  <p>Then in a second file I have this:</p>
  
  <pre><code>#define CONCAT_(A,B,C) A ## B ## C
  #define CONCAT(A,B,C) CONCAT_(A,B,C)
  
  #define ID 0
  
  #define THING_N(A) CONCAT(THING_,ID,A)
  </code></pre>
  
  <p>With this I now have a selection of expressions (still in the second file):</p>
  
  <pre><code>THING_N(_A) // evaluates to 0
  THING_N(_B) // evaluates to 1
  THING_N(_C) // evaluates to... nothing? Or undefined? Or THING_0_C?
  </code></pre>
  
  <p>Now, what I'm trying to work out is how to do this (also still in the second file):</p>
  
  <pre><code>#ifdef THING_N(_A)
      // Do something knowing that THING_N(_A) is defined (in this case THING_0_A)
  #endif
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>#if THING_N(_A)
      // Do something knowing that the value THING_N(_A) evaluates to is defined and not just "nothing"
  #endif
  </code></pre>
  
  <p>Of course neither of these work because #ifdef can't take an expression as an argument (and it would end up as "#ifdef 0" anyway), and THING_N(_A) evaluates to 0 within #if.</p>
  
  <p>In other words, I'm looking for a way to make the preprocessor evaluate:</p>
  
  <pre><code>THING_N(_A) to true
  THING_N(_B) to true
  THING_N(_C) to false
  THING_N(_D) to false
  etc...
  </code></pre>
  
  <p>to be used in a conditional.</p>