Another sizeof question

Yiannis Papelis yiannis at ccad.uiowa.edu
Mon Oct 29 04:57:29 AEST 1990


In article <13171 at crdgw1.crd.ge.com> volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
>Can someone tell me whether "sizeof" expressions are allowed as 
>operands of "#if"? I'm trying to do some conditional compilation
>based on the size of some data structure, and I get parse errors
>before sizeof. The Bible says "sizeof" yields a constant integer,
>and that #if requires an integral constant expression, so I can't
>tell what's wrong. Can someone clue me in? Thanks.
>
>BTW, I'm using gcc to compile.
>

sizeof expressions 'become' a constant integer at compile time.
In other words only the compiler knows what sizeof(whatever) is.
Since the preproccessor runs before the compiler it has no way
of knowing the value of sizeof.

Yiannis E. Papelis
Department of Electrical and Computer Engineering, University of Iowa.
yiannis at eng.uiowa.edu



More information about the Comp.std.c mailing list