title: Using a #define-d list as input to a C preprocessor macro
body: <p>In an example project, I defined the macro</p>
  
  <pre><code>#define FOO(x, y) x + y   .
  </code></pre>
  
  <p>This works perfectly well. For example, <code>FOO(42, 1337)</code> is evaluated to <code>1379</code>.</p>
  
  <p>However, I now want to use another <code>#define</code>:</p>
  
  <pre><code>#define SAMPLE 42, 1337
  </code></pre>
  
  <p>When I now call <code>FOO(SAMPLE)</code>, this won't work. The compiler tells me that <code>FOO</code> takes two arguments, but is only called with one argument.</p>
  
  <p>I guess that the reason for this is that, although, the arguments of a macro are evaluated in advance of the function itself, that the preprocessor does not parse the whole instruction again after this evaluation. This is a similar to the fact that it is not possible to output additional preprocessor directives from a macro.</p>
  
  <p>Is there any possibility to get the desired functionality? </p>
  
  <p>Replacing the <code>FOO</code> macro with a C function is not a possibility. The original macro is located in third party code I cannot change, and it outputs a comma-separated list of values to be directly used in array initializers. Therefore, a C function cannot replicate the same behaviour.</p>
  
  <p>If it is not possible to accomplish this task by using simple means: How would you store the <code>(x, y)</code> pairs in a maintainable form? In my case, there are 8 arguments. Therefore, storing the individual parts in separate <code>#define</code>-s is also not easy maintainable.</p>