structured entry of #if preprocessor commands

David Wolverton daw at cbnewsh.att.com
Thu Feb 14 05:36:00 AEST 1991


In article <1991Feb10.204604.28908 at athena.mit.edu>, scs at adam.mit.edu (Steve Summit) writes:
> What I can't explain is why the following style, which most old
> compilers would accept, has never been widespread (and which
> therefore looks equally weird to me):
> 
>    #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 experimented with this style, but never really fully adopted
it, partly because it isn't widespread, as Steve points out.

But another reason was the early lack of "#elif", which makes
the indentation sometimes look a little weird:

#if CHOICE_1
#   define FOO "abcd"
#else				/* would rather have a single */
#if CHOICE_2			/* #elif CHOICE_2 here */
#   define FOO "efgh"
#else
#if CHOICE_3
#   define FOO "ijkl"
#endif				/* trebled #endif's due to lack */
#endif				/* of #elif */
#endif

Unfortunately, it often seemed to me that precisely the
times when using indentation would clarify the meaning
were also the times when #elif was useful.

Dave Wolverton
daw at attunix.att.com



More information about the Comp.lang.c mailing list