Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: cpp macro expansion Message-ID: <5773@brl-smoke.ARPA> Date: Sat, 18-Apr-87 13:33:19 EST Article-I.D.: brl-smok.5773 Posted: Sat Apr 18 13:33:19 1987 Date-Received: Sun, 19-Apr-87 14:44:12 EST References: <2857@linus.UUCP> <5764@brl-smoke.ARPA> <229@homxb.UUCP> <1062@epimass.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 30 Keywords: cpp, #define, macro In article <1062@epimass.UUCP> jbuck@epimass.UUCP (Joe Buck) writes: >#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... You're assuming that preprocessing is done at a character level rather than a token level, but in fact it is more natural to do it at a token level since that's how macro names and arguments are treated anyway. A tokenizing preprocessor would have no reason to glue together adjacent tokens; that's why X3J11 invented an explicit operator for specifying token pasting. There are a lot of tokenizing C preprocessors already in existence.. By the way, I object the the frequent use of "ANSI breaks this". X3J11 is trying to establish standard meanings for previously underspecified parts of the language that have caused portability problems in the past. ANY assumption you have been making that is not true of ALL C implementations will cause your code to "break" when it's moved to another environment that had different interpretations of the rules. This is not X3J11's doing! It is unavoidable that the eventual ANSI specified C environment will differ in some way from virtually all existing implementations, since they have all come up with mutually incompatible flavors of the language. The hope is that in the long run the ANSI C environment will be both powerful enough and flexible enough to be provided by almost all C implementors and used by almost all C programmers (perhaps as a subset of a wider, system-dependent environment such as POSIX).