context-independent macros
mwm at ucbtopaz.CC.Berkeley.ARPA
mwm at ucbtopaz.CC.Berkeley.ARPA
Fri Feb 1 13:51:50 AEST 1985
Instead of:
# define macro(args)\
if (1) {\
/* macro body */\
}\
else
How about:
#define macro(args)\
(Statement1 ,\
Statement2 ,\
...
Statement3)
This should work correctly anywhere a function call works, as it is a
single statement. The question is whether or not the evaluation order is
preserved. Anybody want to say whether order is/isn't preserved (or do K&R
remain silent), or poke any holes in this?
<mike
For real pain, consider:
#define macro(args) ((state1) + (state2) + ... + (staten))
More information about the Comp.lang.c
mailing list