Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: Standard Clarification Message-ID: <1424@crdos1.crd.ge.COM> Date: 24 Oct 89 17:35:17 GMT References: <20974@gryphon.COM> <1150@crdos1.crd.ge.COM> <23218@cup.portal.com> <1989Oct21.233915.23217@utzoo.uucp> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 42 In article <1989Oct21.233915.23217@utzoo.uucp>, henry@utzoo.uucp (Henry Spencer) writes: | Section 3.8.3 (Oct 1988 draft, roughly current except for wording changes): | | "If a # preprocessing token, followed by an identifier, occurs lexically | at the point at which a preprocessing directive could begin, the identifier | is not subject to macro replacement." | | In other words, ANSI C specifically says that it *doesn't* work. Another thing doesn't work, although it would be useful. If you have macros of the form: #define FOO 123 #define BAR FOO #define DEMO(c) printf("Demo:"#c"\n") then: DEMO(BAR); does not do a substitution of FOO for BAR, nor 123 for FOO. To make this work the value of the argument must be forced to be evaluated first. #define XDEMO(c) DEMO(c) and: XDEMO(BAR); now substitutes 123. This is how I would expect it to work, from the section you quote. Both gcc and a beta of MSC work just that way. Test prog for the terminally curious: #define FOO 123 #define BAR FOO #define X(c) printf("X:"#c"\n") #define TMP(c) X(c) X(FOO); X(BAR); TMP(BAR); -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon