🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #216

Re: Bug (?) in C preprocessor

#216
From: stephenf
Date: Tue, 29 May 1984 19:10
48 lines
2270 bytes
>   From: boyd@basser.SUN (Boyd Roberts)
>   References: <204@elecvax.SUN>
>   Organization: Dept of C.S., University of Sydney
>   
>   No.  The reference manual states:
>   
>   	"Each occurrance of an identifier mentioned in the
>   	formal parameter list of the definition is replaced
>   	by the corresponding token string from the call."

It also state that subsequent occurrences of identifiers used in
ordinary "#define"s are replaced by the appropriate token-string
wherever they occur. What the manual doesn't specify is any order
for replacement.
    
>    	"...the replacement string is rescanned for more
>    	defined identifiers."

Exactly, but which ones come first?
    
>    	"Text inside a string or character constant is not
>    	subject to replacement."

The identifier is not inside a string or character constant. It happens
to be inside another macro, which may introduce quotes at that point,
when replacement occurs. But not until replacement occurrs.
    
>    Hence:
>    
>    #define quote(x)	"x"
>    #define gooeys		sooterkin
>    
>    quote(gooeys) expands to "gooeys" and not "sooterkin".

Your "hence" does not follow at all.
	quote(gooeys)
may first be expanded to
	quote(sooterkin)
and thence to "sooterkin" in complete accordance with the reference
manual. It's not defined.
    
>    I wouldn't advise a change to the preproccessor to do this alternate
>    expansion because by definition it would NOT be the C preproccessor.

By definition where? Not the C reference manual.
    
					- Stephen Frede
					...!decvax!mulga!stephenf:elecvax
Technical Details
Message-ID: <209@elecvax.SUN>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!hou3c!hocda!houxm!hogpc!houti!ariel!vax135!floyd!harpo!decvax!mulga!munnari!basser!elecvax!stephenf
References: <204@elecvax.SUN> <304@basser.SUN>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B UNSW 1.0 3/14/84; site elecvax.SUN
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!hou3c!hocda!houxm!hogpc!houti!ariel!vax135!floyd!harpo!decvax!mulga!munnari!basser!elecvax!stephenf
From: stephenf@elecvax.UUCP
Newsgroups: net.bugs,net.lang.c
Subject: Re: Bug (?) in C preprocessor
Message-ID: <209@elecvax.SUN>
Date: Tue, 29-May-84 15:10:07 EDT
Article-I.D.: elecvax.209
Posted: Tue May 29 15:10:07 1984
Date-Received: Fri, 1-Jun-84 21:58:58 EDT
References: <204@elecvax.SUN> <304@basser.SUN>
Organization: EE and CS, Uni of NSW, Sydney, Australia
Lines: 48