Another sizeof question
Stephen Clamage
steve at taumet.com
Fri Nov 2 04:17:29 AEST 1990
Chris Volpe writes:
>I understand now what the rule is regarding sizeof, and why it is.
>But, could you or someone else point me to a reference in the Standard
>that says that a constant expression in a preprocessor context cannot
>contain sizeof? I'm sure it's in there but I can't find it.
To the preprocessor, sizeof is just an identifier, not a keyword. You
will note that the Standard section 3.8 describes what the preprocessor
recognizes, and sizeof is not mentioned. Neither are "for", "while",
"switch", or other C keywords. Consider this:
int x;
#if goto(x) == 2
or this:
int x;
extern int foo(int);
#if foo(x) == 2
Writing
int x;
#if sizeof(x) == 2
has precisely the same effect. "Goto", "foo", and "sizeof" are treated
by the preprocessor as ordinary identifiers: if they are not #defined
to the proprocessor, they are treated as constant integers with value 0.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.std.c
mailing list