What should be added to C, call
David DiGiacomo
david at sun.uucp
Thu Jun 5 06:13:35 AEST 1986
In article <2600062 at ccvaxa> aglew at ccvaxa.UUCP (Andy "Krazy" Glew) writes:
>Sorry, backslashes don't help macros that I want to have conditional
>sections of code in. Eg. I can't do
>
>#define debugf(parmlist) \
>#ifdef DEBUG \
> printf parmlist \
>#else \
> /* nothing */ \
>#endif
There is a simple way to do this if you are willing to define one extra
macro for each condition you want to test within a macro definition.
#define IFTRUE(a,b) a
#define IFFALSE(a,b) b
#ifdef DEBUG
#define IFDEBUG IFTRUE
#else
#define IFDEBUG IFFALSE
#endif
#define debugf(parmlist) IFDEBUG(printf parmlist, )
More information about the Comp.lang.c
mailing list