C preprocessor question
apn at nonvon.UUCP
apn at nonvon.UUCP
Thu Jan 29 10:33:10 AEST 1987
in article <818 at wjvax.wjvax.UUCP>, brett at wjvax.UUCP (Brett Galloway) says:
>
> 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?
> --
I don't think this should work....
try running 'cc -E file.c' for some clues.
this will give you a output essentially a file
which is what your program looks like to the actual
c compiler after macros are expanded.
CPP evaluates the macro 'GROUP' with arguments 0,0
to be:
(((0) << 8) | ( 0 ))
which is not a valid c line if it is stand alone.
be carefull.. CPP is for just that , preprocessing.... i.e.
#if's are compile time options and not
run time options.
--
Alex P Novickis
UUCP: {seismo, sun, ihnp4, 'etc' }!ptsfa!nonvon!apn
{* Only those who attempt the absurd ... will achieve the impossible *}
{* I think... I think it's in my basement... Let me go upstairs and check. *}
{* -escher *}
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list