Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!decvax!decwrl!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards,comp.unix.questions Subject: Re: need cpp macros to concatenate names Message-ID: <18010@sun.uucp> Date: Mon, 4-May-87 19:12:39 EDT Article-I.D.: sun.18010 Posted: Mon May 4 19:12:39 1987 Date-Received: Tue, 5-May-87 06:49:23 EDT References: <634@calma.UUCP> Sender: news@sun.uucp Distribution: na Lines: 36 Xref: mnetor comp.unix.wizards:2147 comp.unix.questions:2142 > The above works on some preprocessors, not others. Yup. Somewhere between System III and System V, I think, the preprocessor was changed to turn escaped newlines, in the case you mention, into blanks. This is, in fact, incorrect, as I read the ANSI C draft of October 1, 1986, since escaped newlines are to be thrown out fairly early in the processing of the source code. > In all cases, the escaped new line provides token separation. Which is also incorrect, as I read the ANSI C draft. > Our intent is to be portable to any System V machine with a minimum of > changes. > > Anybody have a suggestion? (We know about m4 and sed, but we can't afford to > add another step to the compilation of many thousands of lines of code, which > are all compiled together on a major build of an executable module.) If you really intend to be portable to any conceivable S5-compatible implementation, I suggest you use "m4" and/or "sed", since there's no *documented* way of gluing tokens together in pre-ANSI C. The following trick works on the versions of the "Reiser" preprocessor that are distributed with AT&T UNIX releases, but somebody may have changed things so as to make it not work (unlikely - I know of nobody who has - but not impossible): #define concat(x,y) x/**/y Note, BTW, that you MUST NOT call "concat" as concat(foo, bar) and expect it to glue "foo" and "bar" together - it will glue "foo" and " bar" (note the blank) together.