I don't know if the page is still relevant to this project but
I've posted a simpler and hopefully clearer report on this
I'm reposting here:
#if-block bodies, when expanded as macro arguments, incorrect if #if argument has a macro in it
Example:
#define PASTE_X(X) X
PASTE_X(
BEFORE:
#if HAS_X //same for e.g.: 1*HAS_X+0+2
int x; //this gets replaced by the value of HAS_X
#endif
AFTER:
)
(Compile with e.g., tcc -DHAS_X=42 c.c. The output is then `42` instead of `BEFORE: int x; AFTER:` )
This bug only affects expanded #if-blocks -- if the block isn't passed to a macro (variadic or not)
it expands OK.
If the macro inside the argument to the #if is preceeded by `defined` or enclosed in `defined()`,
the expansion works OK again.
If anyone knows how this might be fixed, please respond.
Best Regards,
Petr Skocik