Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!melba.bby.oz.au!zvs From: zvs@bby.oz.au (Zev Sero) Newsgroups: comp.lang.c Subject: Re: How SHOULD these macros work? Message-ID: <1991Feb19.024059.21585@melba.bby.oz.au> Date: 19 Feb 91 02:40:59 GMT References: <9102151608.AA03533@ucbvax.Berkeley.EDU> Sender: news@melba.bby.oz.au Organization: Burdett, Buckeridge and Young Ltd. Lines: 36 In-Reply-To: schweitz@lexvmc.iinus1.ibm.com's message of 15 Feb 91 16:05:32 GMT Eric = schweitz@lexvmc.iinus1.ibm.com ("Eric Schweitz") Eric> I have a question concerning the preprocessor. Namely, what behavior Eric> SHOULD be expected from the following: Eric> #define one val1,val2 Eric> #define two(arg1,arg2) arg1+arg2 Eric> .... Eric> two (one) // ? Eric> Should this evaluate to: Eric> a) val1+val2 Eric> -or- Eric> b) val1,val2+ The correct answer is b. I quote from H&S 2, page 33: Once a macro call has been expanded, the scan for macro calls resumes at the beginning of the expansion; this is so that names of macros may be recognized within the expansion for the purpose of further macro replacement...Macro replacement is also not performed within the actual argument token strings of a complex macro call at the time the macro call is being scanned. Macro names are recognised within actual argument token strings only during the rescanning of the expansion. Therefore your macro is expanded in the following steps: two (one) --> one+ At this point one is not recognised as a macro. Then the expression is rescanned: one+ --> val1,val2+ -- Zev Sero - zvs@bby.oz.au This I say unto you, be not sexist pigs. - The prophetess, Morgori Oestrydingh (S.Tepper)