C preprocessor question
moss at BRL.ARPA
moss at BRL.ARPA
Sat Jan 31 04:31:37 AEST 1987
Brett Galloway writes...
>I have a question about the C preprocessor. I have the following code
>fragment, which fails to compile on my system (4.2BSD):
>
>#define GROUP(group,subgroup) (((group) << 8) | (subgroup))
>
>#if GROUP(0,0)
>#endif
>
>The #if chokes for some reason. Can anyone in comp.lang.c see my error?
>If there is no error, is this a known bug of the 4.2BSD cpp?
The pre-processor defined macros are not evaluated by CPP. In other
words, "#if GROUP(0,0)" is illegal because GROUP(0,0) has no value.
You might want to use:
if( GROUP(0,0) )
...
instead. Or, maybe you meant to say:
#if defined( GROUP )
...
#endif
-moss
More information about the Comp.lang.c
mailing list