structured entry of #if preprocessor commands

Jason Smigiel umsmigie at ccu.umanitoba.ca
Sun Feb 10 17:39:15 AEST 1991


	 
 
Is it common practice not to structure preprocessor commands in ANSI C?
 
I've been staring at code that reads like this:
 
   #if defined(MSDOS)
   #if defined(ANSI)
   #include "ms_ansi.h"
   #endif
   #else /* not msdos */
   #if !defined(ATARIST_MWC) && !defined(MAC) && !defined(AMIGA)
   #ifndef VMS
   #include <sys/ioctl.h>
   #endif
   #include <signal.h>
   #endif
   #endif
 
While it makes a lot more sense to me to write it something like this:
 
   #if defined(MSDOS)
      #if defined(ANSI)
      #include "ms_ansi.h"
      #endif
   #else /* not msdos */
      #if !defined(ATARIST_MWC) && !defined(MAC) && !defined(AMIGA)
         #ifndef VMS
         #include <sys/ioctl.h>
         #endif
      #include <signal.h>
      #endif
   #endif
 
I looked in the K&R2 reference manual, under A12,(very first paragraph) and
it states:
 
    "Lines beginning with #, perhaps preceeded by white space, communicate
    with this preprocessor."
 
  So it seems completely valid to me, I just wanted to know if this was a smart
thing to do or am I entirely insane?
 
Jason Smigiel
umsmigie at ccu.umanitoba.ca



More information about the Comp.lang.c mailing list