3B2 cpp #ifdef + #include

Steven Sargent sarge at sham.Berkeley.EDU
Sat Apr 2 21:10:51 AEST 1988


In article <109 at iquery.UUCP>, matt at iquery.UUCP (Matt Reedy) writes:
> Has anyone else noticed this on the 3B2 (using C Programming Languages
> Issue 4 Version 0)?
> 
> Code fragment:
> 
> #ifdef XXXXX
> junk junk
> #include junk
> #endif
> 
> main ()
> {
> 	return 0;
> }
> 
> If it is compiled using 'cc -c -O junk.c', cpp says:
> 
> junk.c: 3: bad include syntax
> 
> Why is cpp trying to interpret the #include when the #ifdef is NOT true?
> It doesn't complain about the 'junk junk' line, only the #include line!
> 
> -- 
> Matthew Reedy				harvard!adelie!iquery!matt
> Programmed Intelligence Corp.		(512) 822 8703
> 830 NE Loop 410, Suite 412		"just ONE MORE compile...."
> San Antonio, TX  78209-1209

Ain't just 3b2, y'know: anybody using C 4.0 gets the same "benefit."
I have to compile on UNIX and VMS, and so ran into this myself.
Apparently TPC is running a full-employment program, and rather than
building roads and dams, they keep busy by making annoying changes
to cpp... here's another one:

#ifdef vms
do$vms$stuff$with$lots$of$signs
#else vms
do something else
#endif vms

The new improved cpp prints warnings about "tokens after directive
(ignored)" after the #else and #endif lines.  Not fatal to the
compilation, but distracting to look at, and no help.  (Yes, I can
sed my source and fix the damn things -- certainly
#endif /* vms */
is an acceptable solution.  But why do they bother?)

S.
---
"I'm sorry... you must have me confused with some other plate-lipped
white girl named Irene."
				-- Good Girls #2

Steven Sargent
ARPA Internet: sarge at scam.berkeley.edu
MILnet: sarge%scam.berkeley.edu at ucbvax.berkeley.edu
TPCnet: {anywhere at all, really}!ucbvax!scam!sarge



More information about the Comp.unix.wizards mailing list