Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Expansion of macro arguments in ANSI cpp. Message-ID: <685@taumet.com> Date: 23 Apr 91 15:19:04 GMT References: <2610@otc.otca.oz> Organization: Taumetric Corporation, San Diego Lines: 26 grahamd@otc.otca.oz.au (Graham Dumpleton) writes: > #define preone onepre > #define one two > #define addpre(arg) pre##arg > addpre(one) >The preprocessor on a RS6000 running AIX when run with the argument >'-qlanglvl=ansi' to invoke ANSI compatability produces > onepre >The pre-processor which we use though, which is based on the Decus cpp supplied >on the X tape produces the following > pretwo >I tend to think that the Decus cpp is wrong but can someone please confirm this. Decus is wrong. Section 3.8.3.1 of the Standard decribes how macro argument substitution operates. After identifying the arguments, those which are neither preceeded by # or ##, nor followed by ##, are fully macro-replaced; the others are left alone. In your example, the 'arg' macro is preceeded by ##, so its actual parameter is not expanded. After concatenation, we have 'preone', which is then rescanned to produce 'onepre'. -- Steve Clamage, TauMetric Corp, steve@taumet.com