tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] bug: #if-block bodies, when expanded as macro arguments,


From: Petr Skočík
Subject: [Tinycc-devel] bug: #if-block bodies, when expanded as macro arguments, incorrect if #if argument has a macro in it
Date: Wed, 23 May 2018 13:34:57 +0200

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
bug at: https://savannah.nongnu.org/bugs/?group=tinycc

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]