🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1916

Re: Another sizeof question

#1916
From: Stephen Clamage
Date: Thu, 01 Nov 1990 17:17
26 lines
1463 bytes
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@taumet.com
Technical Details
Message-ID: <497@taumet.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!sun-barr!lll-winken!uunet!taumet!steve
References: <13171@crdgw1.crd.ge.com> <1990Oct28.223702.27918@zoo.toronto.edu> <13294@crdgw1.crd.ge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!sun-barr!lll-winken!uunet!taumet!steve
From: steve@taumet.com (Stephen Clamage)
Newsgroups: comp.std.c
Subject: Re: Another sizeof question
Message-ID: <497@taumet.com>
Date: 1 Nov 90 17:17:29 GMT
References: <13171@crdgw1.crd.ge.com> <1990Oct28.223702.27918@zoo.toronto.edu> <13294@crdgw1.crd.ge.com>
Organization: Taumetric Corporation, San Diego
Lines: 26