Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!ames!amdcad!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Portability and /**/ Message-ID: <24624@sun.uucp> Date: Fri, 31-Jul-87 13:45:12 EDT Article-I.D.: sun.24624 Posted: Fri Jul 31 13:45:12 1987 Date-Received: Sun, 2-Aug-87 02:56:10 EDT References: <949@oakhill.UUCP> <23575@sun.uucp> <4983@prls.UUCP> <118@geovision.UUCP> Sender: news@sun.uucp Lines: 63 > You are right, the C pre-processor does (normally) strip out the comments. > However, the exact semantics depend on the particular version (BSD or > SYSV) of 'cpp'. There *are* uses for this -- you note one. The C++ > compiler (which also uses 'cpp') uses a similar mechanism to allow definition > of generic classes. The file has code something like: > > #ifdef BSD /* BSD way */ > #define name2(a,b) a\ > b > #else /* System V way */ > #define name2(a,b) a/**/b > #endif I don't understand this. I have seen this several times, and I still don't understand this. Why is the second way labeled "System V way", and the first way labeled "BSD way"? gorodish$ rlogin sunvax Password: Last login: Sat Jul 18 00:53:39 from gorodish 4.3 BSD UNIX #1: Mon Jul 7 11:46:47 PDT 1986 *** N.B.: Running straight 4.3bsd. *** % ed foo.c ?foo.c a #define name2(a,b) a/**/b name2(foo,bar) . w 42 q % cc E foo.c # 1 "foo.c" foobar The second way, mislabeled "System V way", works just fine on 4.3BSD; the C preprocessor hasn't changed much at all between 4.1BSD and 4.3BSD, other than having the "-M" flag added. The "System V way" is used in several places by 4BSD Makefiles. If you're using a Reiser preprocessor, the "System V way" will almost certainly work. If you're not using a Reiser preprocessor, *neither* of the ways is guaranteed to work. (If you're using an ANSI C preprocessor, there is, of course, a standard way of doing this that *is* guaranteed to work, unless they change that part of the standard before it becomes final.) Note, by the way, that due to the Reiser preprocessor's Principle of Least Surprise-violating way of handling white space in macro calls, the following call of "name2" will not work with *either* of the two definitions above: name2(foo, bar) It expands to "foo bar", because the second argument is " bar", not "bar". Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com