'sizeof' in preprocessing.

Stan Brown, Oak Road Systems browns at iccgcc.decnet.ab.com
Tue Oct 9 01:24:50 AEST 1990


In article <1990Oct6.092032.345 at csc.canberra.edu.au>, eyal at echo.canberra.edu.au (Eyal Lebedinsky) writes:

> Reading the standard, any 'constant-expression' is valid for #if, and sizeof
> is yielding a constant. So, one should be able to say:
> #if sizeof (a) == 2
> etc. I read it a while ago and though it too bad my compiler won't do this.
> No separate cpp will do it (unless it learns some C).
> Comments? I was reading 3.8.1 7/88 draft.
 
I thing the preprocessor doesn't know C--specifically, the preprocessor
doesn't know your variable names.  For example, the following should be
a strictly conforming program and should compile successfully, assuming
"mumble" occurs nowhere else in the compilation:

    int mumble;
    #ifdef mumble
    #     error  The C preprocessor goofed
    #else
          /* This is the way it's supposed to work. */
    #endif

The above opinions are not attributable to any other person or company.
                                     email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, U.S.A.   +1 216 371 0043



More information about the Comp.std.c mailing list