__STDC__ defined as zero a problem

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Sat Jun 24 05:32:00 AEST 1989


I have noticed several programs posted to the net, or available
by ftp somewhere that contain lines like

#if __STDC__
  /* usually function prototypes */
#else
  /* old style declarations */
#endif

I find this a bit objectionable, in that this prevents getting the
benefits of new-style declarations using compilers that support them
but, correctly, declare __STDC__ to be zero or don't declare it at all.

It would be nice if they looked something like

#ifdef ANSI_prototypes
#undef ANSI_prototypes
#define ANSI_prototypes 1
#else
#define ANSI_prototypes 0
#endif

#if ((__STDC__) | (ANSI_prototypes))
  /* the rest as above....

Where ANSI_prototypes could be defined on the command line.

I admit that sort of stuff could lead to command-line pollution
by things like defining ANSI_trigraphs, ANSI_this, ANSI_that, etc.

On the other hand, though __STDC__ is supposed to be defined as 1 
for comforming compilers , and not redefinable, (is this correct,
standards gurus?) it might be possible in a not-really ANSI-C
compiler to make __STDC__ be defined as 0, and redefinable. The
standard surely shouldn't object to this, should it?

Your comments and flames are welcome.

Doug McDonald (mcdonald at uxe.cso.uiuc.edu)
 



More information about the Comp.lang.c mailing list