🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1895

Re: Another sizeof question

#1895
From: Doug Gwyn
Date: Mon, 29 Oct 1990 00:50
17 lines
1506 bytes
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"? 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.

While the identifier "sizeof" may be used in the integral constant
expression controlling conditional inclusion (i.e. operand of #if),
you need to be aware that this stuff occurs during translation phase
4, involving preprocessing tokens, not "pure C language" tokens.
Thus, language keywords (such as "sizeof") have no special meaning;
identifiers are macro-substituted and any that had no substitutions
are then replaced with "0".  It is the result of that substitution
that is evaluated for the constant expression.  Thus, there can be no
enumeration constants, types, and so forth involved in the condition.
Technical Details
Message-ID: <14269@smoke.brl.mil>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!adm!smoke!gwyn
References: <13171@crdgw1.crd.ge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!adm!smoke!gwyn
From: gwyn@smoke.brl.mil (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: Another sizeof question
Message-ID: <14269@smoke.brl.mil>
Date: 29 Oct 90 00:50:07 GMT
References: <13171@crdgw1.crd.ge.com>
Organization: U.S. Army Ballistic Research Laboratory, APG, MD.
Lines: 17