Single line conditional compiles
random@bubblescope.net
random@bubblescope.net
Thu Jul 28 16:08:00 GMT 2005
Gerrit van Niekerk wrote:
>How can one implement single line conditional compile macros with GCC?
>
>Instead of having:
>
>#ifdef OPT1
><valid C line>
>#endif
>
>Having something like:
>IFOPT1 <valid C line>
>
>The following works with BorlandC, but not GCC:
>
>#ifdef OPT1
>#define IFOPT1
>#else
>#define IFOPT1 /##/
>#endif
>
>I understand why it does not work - I am looking for a solution, not an
>explanation :)
>
>
>
Not quite what you are looking for, but how about?
#ifdef OPT1
#define IFOPT1(x) x
#else
#define IFOPT1(x)
#endif
Then you write
IFOPT1(stuff)
This has the advantage you can write it mid-line, with stuff before and
after it.
Chris
More information about the Gcc-help
mailing list