Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 Apollo 1/28/85; site apollo.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!talcott!panda!genrad!decvax!wanginst!apollo!nazgul From: nazgul@apollo.uucp (Kee Hinckley) Newsgroups: net.lang.c Subject: CC bug test Message-ID: <2479686f.8e4@apollo.uucp> Date: Wed, 30-Jan-85 10:51:03 EST Article-I.D.: apollo.2479686f.8e4 Posted: Wed Jan 30 10:51:03 1985 Date-Received: Sat, 2-Feb-85 09:47:46 EST Organization: Apollo Computer, Chelmsford, Mass. Lines: 40 ... This applies mainly to BSD users, but everyone is free to try. I've seen several pieces of code out there that say "#ifdef V4.2". Nothing wrong with that, right? WRONG. The K&R state that macros are identifiers, and identifiers DON'T have '.'s in them. If they did how would you do structure references? I have been told that in fact "V4.2" works only because the Berkeley compilers ignore the ".2". If this is the case then two things are true. The following shell script is NOT going to do what you expected, and someone had better come up with a better "#ifdef". I rather hope that the latter is done regardless of the former, since strict C compilers won't compile a program that says "#ifdef V4.2". Which makes it a bit of a pain for those of us who port the torrents of stuff coming across the net. Here goes. main() { printf("Currently compiling only"); #ifdef V4 printf(" V4"); #endif #ifdef V4.1 printf(" V4.1"); #endif #ifdef V4.2 printf(" V4.2"); #endif printf(" lines.\n"); } -Kee Hinckley ...decvax!wanginst!apollo!nazgul P.S. I don't think there are any syntax errors in the above program (other than the one in question), but I don't guarantee it since I can't compile it!