In C99, we have compound literals, and they can be passed in functions, as in:
f((int[2]){ 1, 2 });
However, if f not a function, but rather a function-like macro, gcc barfs is on it because the preprocessor parses it not as one argument, but as two arguments, " (int[2]){ 1 " and " 2 } ".
Is this a bug in gcc or in the C standard? If this is the latter, it pretty much rules out all the transparent use of functionally-like macros that seem like a huge defect ...
Edit: As an example, you can expect the following program fragment to match:
fgetc((FILE *[2]){ f1, f2 }[i]);
But since fgetc can be implemented as a macro (although it is necessary to protect its argument and does not evaluate it more than once), this code would indeed be incorrect. It seems amazing to me.
c gcc c-preprocessor c99
R ..
source share