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

Jim Hunt hunt at ernie.Berkeley.EDU
Wed Oct 4 15:00:04 AEST 1989


In article <11212 at smoke.BRL.MIL> gwyn writes:
>In <17936 at pasteur.Berkeley.EDU> hunt at ernie.Berkeley.EDU.UUCP (Jim Hunt) writes:
>>You can do this in non ANSI environments (at least Sun) with
>>#define MyInit(arg)   arg/**/Init
>What are you talking about?  That's two tokens, not one spliced one,
>in both Standard C and K&R C.  It was the UNIX (Reiser) cpp that was
>responsible for this misimplementation becoming widespread.

Exactly, and it still works.  I think this is what the ## was
INVENTED for.  To make the standard conform to the existing
bugs/flaws/features in most systems.  I mentioned that so those
who do NOT have ansi compilers, can have a method to do all the
things that ANSI is supposed to bring down from the Gods.

I have tried it on all machines I have access to, and I still
haven't found one where it fails.  I would rather do ##, but
until all non-ansi compilers are erased from the disks of the
world, this is an option to remember.

Question, what do ansi compilers do with that?  They don't HAVE
to have a pre-processor, but who doesn't, and if there is a PP,
which eliminates /*comments*/, what token does it put in to
identify where comments were?  Would you complicate your yacc by
allowing comment tokens everywhere?  NO!  I guess the solution
would be in the lex phase, but I still think you are fighting
hard to eliminate a rather harmless artifact of the fact that
you use a preprocessor.

jim hunt at ernie.Berkeley.EDU	H&H Enterprises (1 employee)
These ARE the bosses opinions, I AM the * boss!!!
grad UCB, MS EE/CS, May 90, resume on request.



More information about the Comp.lang.c mailing list