Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!epiwrl!epimass!jbuck From: jbuck@epimass.UUCP Newsgroups: comp.lang.c Subject: Re: cpp macro expansion Message-ID: <1062@epimass.UUCP> Date: Fri, 17-Apr-87 21:47:41 EST Article-I.D.: epimass.1062 Posted: Fri Apr 17 21:47:41 1987 Date-Received: Sat, 18-Apr-87 08:19:44 EST References: <2857@linus.UUCP> <5764@brl-smoke.ARPA> <229@homxb.UUCP> Reply-To: jbuck@epimass.UUCP (Joe Buck) Organization: Entropic Processing, Inc., Cupertino, CA Lines: 30 Keywords: cpp, #define, macro In article <5764@brl-smoke.ARPA>, gwyn@brl-smoke.UUCP writes: >> "token pasting". People using the Reiser CPP (found on most >> UNIX systems) typically resorted to the following trick: >> #define GLUE(a,b) a/**/b >> However, this is not guaranteed to work and, indeed, is >> guaranteed NOT to work in X3J11-compliant compilers. The >> X3J11 invention for token pasting is: >> #define GLUE(a,b) a ## b >> You will probably not find many compilers implementing this >> yet, since this part of the spec kept changing. In article <229@homxb.UUCP> gemini@homxb.UUCP (Rick Richardson) writes: >And we of course have a third method here at AT&T. The >preprocessor distributed with 4th generation make uses: > #define GLUE(a,b) a\+b >Can you say non-compliant? I knew you could. I use #define QUOTE(x) x #define GLUE(x,y) QUOTE(x)y Well, it works for me, and it's prettier than a/**/b. Can't tell whether ANSI breaks this: I suppose a conforming compiler could "tokenize" things before the preprocessor is invoked (or there may be no separate preprocessor pass) -- but I like it. -- - Joe Buck {hplabs,ihnp4,sun,ames}!oliveb!epimass!jbuck seismo!epiwrl!epimass!jbuck {pesnta,tymix,apple}!epimass!jbuck