Expansion of macro arguments in ANSI cpp.

Graham Dumpleton grahamd at otc.otca.oz.au
Tue Apr 23 11:38:03 AEST 1991


I checked the FAQ list but couldn't find this mentioned so:

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)


The preprocessor on a RS6000 running AIX when run with the argument
'-qlanglvl=ansi' to invoke ANSI compatability produces

onepre

In other words it performs the join and then checks to see if the result
is a macro and if so expands it.

The pre-processor which we use though, which is based on the Decus cpp supplied
on the X tape produces the following

pretwo

In other words it has the effect of expanding the argument if it is a macro
first and then performing the join.

I tend to think that the Decus cpp is wrong but can someone please confirm this.

--
Graham Dumpleton (grahamd at otc.otca.oz.au)



More information about the Comp.lang.c mailing list