Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!seismo!ll-xn!cullvax!drw From: drw@cullvax.UUCP (Dale Worley) Newsgroups: comp.sources.d Subject: ANSI C preproccessor concatenate Message-ID: <1449@cullvax.UUCP> Date: Tue, 11-Aug-87 14:17:51 EDT Article-I.D.: cullvax.1449 Posted: Tue Aug 11 14:17:51 1987 Date-Received: Thu, 13-Aug-87 04:45:25 EDT Organization: Cullinet Software, Westwood, MA, USA Lines: 31 allbery@ncoast.UUCP (Brandon S. Allbery) writes: - The reason for this is that I have a cpp macro which provides function proto- - types under ANSI C and omits them for old-fashioned C. Example: - - DEFUN(extern generic malloc, (unsigned)); - - becomes - - extern generic malloc(unsigned); [Under ANSI C he writes:] - #define DEFUN(fn,proto) fn##proto - - It assumes that X3J11 is #defined by ANSI C (wrong, I'm certain) and that the - concatenation operator is ## (I think this is right). (Purists would argue - that ## isn't needed; but I have a thing about "xx (yy)" as a function defi- - nition; I want to search for functions with "xx(" and C control structures - (if, while, switch) with "xx (".) You'll lose big if you try this! The reason is that the ## operator concatenates the character representation of the two surrounding tokens to form what must be the character representation of a token. Calling DEFUN(func,(a,b)) tries to concatenate the two tokens "func" and "(", which together don't form a token. Dale -- Dale Worley Cullinet Software ARPA: cullvax!drw@eddie.mit.edu UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw OS/2: Yesterday's software tomorrow Nuclear war? There goes my career!