Expansion of macro arguments in ANSI cpp.

Stanley Friesen sarima at tdatirv.UUCP
Wed Apr 24 05:21:03 AEST 1991


In article <2610 at otc.otca.oz> grahamd at otc.otca.oz.au (Graham Dumpleton) writes:
<What is an ANSI conforming C preprocessor mean't to do in the following
<situation.
<
<#define preone onepre
<#define one two
<#define addpre(arg) pre##arg
<
<addpre(one)

I believe that the ANSI standard requires that macro arguments be expanded
before substitution into the macro body, and therefor before expansion of
the macro itself into the source.

Thus the answer is:

pretwo
 
<The preprocessor on a RS6000 running AIX ...
 
<onepre
 
I believe that this is *wrong* per the standard.
(I do not actually have a copy present with me, so I could be wrong).
-- 
---------------
uunet!tdatirv!sarima				(Stanley Friesen)



More information about the Comp.lang.c mailing list