Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!linus!security!ms From: ms@security.UUCP Newsgroups: comp.lang.c Subject: cpp macro expansion Message-ID: <2857@linus.UUCP> Date: Wed, 15-Apr-87 15:00:35 EST Article-I.D.: linus.2857 Posted: Wed Apr 15 15:00:35 1987 Date-Received: Fri, 17-Apr-87 03:32:10 EST Sender: news@linus.UUCP Lines: 35 Keywords: cpp, #define, macro Sorry if this has been discussed before in reference to X3J11 discussions, or other C problems encountered, but I haven't been reading this newsgroup very long. I have a question concerning the expansion of a #define by cpp on a Sun 3/160 running UNIX 4.2BSD version 3.2 from Sun Microsystems. Consider the following macro (this is not the actual code used, but will serve as a typical example): #define MACRO(first,last) (\ first\ _\ last) The intent of the developers was that when cpp expands the code, the two macro arguments would be concatenated together into one token for the compiler, i.e: MACRO(holy,cow) yields (holy_cow). However our cpp under 3.2 insists on replacing the escaped newlines in the macro with spaces, i.e: (holy _ cow), which the compiler then spits out. I tried this same example on Sun 3/160 running 3.0, and a Vax 11/780 running 4.2BSD, and both expanded the macro without the spaces. A quick glance through K&R did not yield any insight into which expansion is correct, but I may have overlooked something. So, my questions are: Which is the correct expansion, or is it left to the cpp implementors? Is there a problem with the (our?) Sun version 3.2 cpp? What (if anything) does the new standard say about this? Many thanks for any assistance you can provide. Jay W. Davison (Mistress Account) decvax!linus!security!ms jwd@mitre-bedford.arpa