Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mimsy!oddjob!gargoyle!ihnp4!homxb!mhuxt!mhuxm!mhuxo!ulysses!sfmag!sfsup!mpl From: mpl@sfsup.UUCP (M.P.Lindner) Newsgroups: comp.lang.c Subject: Re: Portability and /**/ Message-ID: <1647@sfsup.UUCP> Date: Fri, 17-Jul-87 10:07:25 EDT Article-I.D.: sfsup.1647 Posted: Fri Jul 17 10:07:25 1987 Date-Received: Sat, 18-Jul-87 18:45:08 EDT References: <949@oakhill.UUCP> <23575@sun.uucp> <4983@prls.UUCP> Organization: AT&T-IS, Summit N.J. USA Lines: 37 Summary: brain damage! In article <4983@prls.UUCP>, gardner@prls.UUCP writes: > We recently received a large amount of code written for our > Unix VAX in C. It's device driver routines make extensive use > of an interesting construct -- a rather large number of #defines > are of the form: > #define a(n) a/**/n The C++ compiler generates things of this form to concatenate names for the same reason - you avoid naming conflicts by concatenating the name with some type information or something. Apparently, this is making use of an obscure BUG in the C preprocessor as implemented under UNIX(R) SYS V. Before you send flames that this is NOT a bug, realize that, as the poster of the original article pointed out, by not replacing the comment with white space, the preprocessor is changing the semantics of the code! I know, it's SUPPOSED to change the code, but this is abominable! K&R specify that comments act as white space and may be used anywhere white space may be used. This implies that a/**/b == a b which is NOT the case! I therefore claim the preprocessor is broken and if you want to concatenate symbols, perhaps you should design a feature in the preprocessor to do so, rather than exploit a bug! Oh, by the way, BSD systems use #define blah(a,b) a\ b to do the same thing (concatenate a and b). This seems more reasonable, since K&R state that a '\' and an immediately following newline are ignored (at least in strings). BOTH of these methods has the disadvantage that white space in the arg list will break the intention of the macro, so they don't preserve the "free format" concepts of C. For example: blah(abc, def) will NOT work, while blah(abc,def) will. This took me 3 days to debug when I was learning C++.