Concatenating with a compile-time definition in "ANSI" CPP

Richard O'Keefe ok at cs.mu.oz.au
Wed Oct 4 17:18:33 AEST 1989


In article <17936 at pasteur.Berkeley.EDU>, hunt at ernie.Berkeley.EDU (Jim Hunt) writes:
> You can do this in non ANSI environments (at least Sun) with
> #define MyInit(arg)   arg/**/Init
> which is an ugly hack on the preprocessor, that is also defined
> in the ANSI C preprocessor!

Yes, the ANSI standard does define the behaviour of arg/**/Init, but
it defines it *NOT* to work.  In "Reiser" preprocessors, comments got
turned into nothing at all.  In ANSI preprocessors, comments get turned
into one blank.  So MyInit(Bogus) would turn into "BogusInit" in a
"Reiser" preprocessor, but into "Bogus Init" in an ANSI-conformant one.

I have found gcc extremely helpful for coming to grips with things like
this; I use "gcc -ansi -pedantic" all the time just to be safe.  If my
code works under both that and "gcc -traditional" and if "lint" likes it
I begin to feel that I may not have overlooked obvious non-portabilities.



More information about the Comp.lang.c mailing list