Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Another sizeof question
Message-ID: <1990Oct28.223702.27918@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <13171@crdgw1.crd.ge.com>
Date: Sun, 28 Oct 90 22:37:02 GMT

In article <13171@crdgw1.crd.ge.com> volpe@camelback.crd.ge.com (Christopher R Volpe) writes:
>Can someone tell me whether "sizeof" expressions are allowed as 
>operands of "#if"? ...

In ANSI C, no, they are not.  Preprocessing is done before there is any
notion of declarations, types, storage layout, or sizes.  In a #if, `sizeof'
is just another identifier.

>...The Bible says "sizeof" yields a constant integer,
>and that #if requires an integral constant expression, so I can't
>tell what's wrong...

It's not clear which Bible you are reading. :-)  Is it the Old Testament
(K&R1), the New Testament (K&R2), or the New American Edition (ANSI)?
In a sufficiently modern and complete edition, you will find the rule
against this down in the fine print.

>BTW, I'm using gcc to compile.

Note that GNU C and standard C are only somewhat related.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry@zoo.toronto.edu   utzoo!henry
