Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!ginosko!cg-atla!fredex From: fredex@cg-atla.UUCP (Fred Smith) Newsgroups: comp.lang.c Subject: Re: Concatenating with a compile-time definition in "ANSI" CPP Message-ID: <7730@cg-atla.UUCP> Date: 4 Oct 89 12:48:35 GMT References: <470004@gore.com> <29351@watmath.waterloo.edu> <17936@pasteur.Berkeley.EDU> <11212@smoke.BRL.MIL> <17975@pasteur.Berkeley.EDU> Reply-To: fredex@cg-atla.UUCP (Fred Smith) Organization: Agfa Compugraphic Division Lines: 33 In article <17975@pasteur.Berkeley.EDU> hunt@ernie.Berkeley.EDU.UUCP (Jim Hunt) writes: >In article <11212@smoke.BRL.MIL> gwyn writes: >>In <17936@pasteur.Berkeley.EDU> hunt@ernie.Berkeley.EDU.UUCP (Jim Hunt) writes: >>>You can do this in non ANSI environments (at least Sun) with >>>#define MyInit(arg) arg/**/Init > >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. > Well, Microsoft C may not be a flawless ANSI implementation, but it is somewhere in the ballpark, and when you give it that construct it thinks you are talking about two different items named arg, and Init. This is reasonable, and I think correct behavior. If one reads K&R, or ANSI standard, one will see that they both state that comments in the source are replaced with WHITE SPACE in the preprocessor phase of translation. Clearly, if comments become whtie space, then this ugly hack (i.e., "/**/", which is, after all, a comment!!) will not result in arg and Init being pasted together!!!! This usage, then, is clearly an aberration on what the language was originally intended and documented to be. Not to say that it isn't useful, though, which is, I am sure, why the standard committee chose to specify an official, blessed, way to doing it. Fred Smith