Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site wateng.UUCP Path: utzoo!watmath!wateng!ksbszabo From: ksbszabo@wateng.UUCP (Kevin Szabo) Newsgroups: net.lang.c Subject: Re: CC bug test Message-ID: <1961@wateng.UUCP> Date: Sun, 3-Feb-85 22:28:50 EST Article-I.D.: wateng.1961 Posted: Sun Feb 3 22:28:50 1985 Date-Received: Mon, 4-Feb-85 05:29:26 EST References: <2479686f.8e4@apollo.uucp> <780@sdcsla.UUCP> Reply-To: ksbszabo@wateng.UUCP (Kevin Szabo) Distribution: net Organization: VLSI Group, U of Waterloo Lines: 42 Summary: In article <780@sdcsla.UUCP> west@sdcsla.UUCP (Larry West) writes: >In article <2479686f.8e4@apollo.uucp> nazgul@apollo.uucp (Kee Hinckley) writes: >>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"); >>} > >Hmmm. On both our Vax and Sun (both 4.2bsd, more or less), the result >of running this program is: "Currently compiling only lines.". Well, on our BSD4.2 machine, the following command sequence cc -DV.2 test.c; a.out produces: Currently compiling only V4 V4.1 V4.2 lines. as the original author stated. To repeat the author (in case anybody missed the original posting). A `.' (period) is not legal part of an identifier, either in the preprocessor or in C. BSD software allows you to use a period in preprocessor identifiers, but it quietly truncates the period and trailing part of the string. Could cause some confusing bugs... Kevin P.S. Plug time: In Henry Spencer's annotated Indian Hill C Style and Coding standards he states: If you #ifdef dependencies, make sure that if no machine is specified, the result is a syntax error, not a default machine. ..Why am I saying this? I don't know, just seemed like a good time to spout off. I know that following this advice has saved some users of my code a good deal of heartache.. -- Kevin Szabo watmath!wateng!ksbszabo (U of Waterloo VLSI Group, Waterloo Ont.)