Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site opus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!floyd!cmcl2!seismo!hao!cires!nbires!opus!rcd From: rcd@opus.UUCP Newsgroups: net.lang.c Subject: Forming composite tokens (3 ways) Message-ID: <465@opus.UUCP> Date: Tue, 8-May-84 21:16:06 EDT Article-I.D.: opus.465 Posted: Tue May 8 21:16:06 1984 Date-Received: Sat, 12-May-84 09:45:53 EDT References: <476@decvax.UUCP> <2511@watcgl.UUCP> Organization: NBI, Boulder Lines: 33 It has already been noted (see ref) that you can concatenate tokens with the preprocessor (at least in 4.x BSD; I don't know whether this is epidemic) with: #define CAT(x,y) x/**/y with the preprocessor discarding comments. As noted earlier, this is not only grungy, it gives lint a lot of grief. --- A second solution is to use the interpretation of \ at end of line: #define CAT(x,y) x\ y which seems a little cleaner, but I'm still dubious; it seems like a dark corner. I think it's safe to conclude that the preprocessor can't rejoin lines when the first ends with \, but that the lex. analyzer must do so... Still, I don't like it very much. --- Yet a third, and in some sense the one that seems least grungy (but it's the fault of nbires!vjs if you don't like it:-) is: #define I(x) x #define CAT(x,y) I(x)y I is just an "identity macro" which gives you a chance to get something between the x and y (a parenthesis) in the definition of CAT. --- Anyone care to comment on esthetics? I'd also like to hear of compilers for which the latter two don't work. -- ...Nothing left to do but smile, smile, smile. Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303) 444-5710 x3086