3B2 cpp #ifdef + #include

Karl Heuer karl at haddock.ISC.COM
Wed Mar 30 03:22:52 AEST 1988


In article <3127 at csli.STANFORD.EDU> gandalf at csli.stanford.edu (Juergen Wagner) writes:
>The problem with your cpp is that all the lines starting with # have to
>be valid syntax, i.e. "junk junk" is not relevant because it is just text
>and cpp doesn't know if this is correct or not, but "# include junk" is
>invalid because is violates cpp syntax.

"#include junk" is legal (in ANSI C, anyway) if "junk" is a macro that expands
into a quoted or embroketed header name.  Thus,
  #ifdef junk
  #include junk
  #endif
should be legal.  This is indeed a bug in certain preprocessors.  Similarly, I
believe that the warning produced by
  #ifdef vms
  #ifdef foo$bar /* a valid name, in VMS */
  #endif
  #endif
on non-VMS systems is inappropriate, though I haven't yet determined what the
latest dpANS says about this.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
Followups to comp.lang.c only.



More information about the Comp.unix.wizards mailing list