MSC __STDC__ strange value

Dion Hollenbeck hollen at eta.megatek.uucp
Wed Dec 6 02:41:34 AEST 1989


>From article <223 at bohra.cpg.oz>, by ejp at bohra.cpg.oz (Esmond Pitt):
> For some strange reason, the MSC 5.1 compiler defines __STDC__ as 0, so
> 
> #if __STDC__
> ...
> #endif

This means:  Take the DEFINED macro __STDC__ and test its value and
		return TRUE if non-zero and FALSE if zero

> 
> yields a different result from
> 
> #ifdef __STDC__
> ...
> #endif
> 
> Why?

This means:	Look to see if the macro __STDC__ is defined. If
		it is defined, return TRUE and if it is not defined
		return FALSE.

The difference is the basic definition of #if and #ifdef.  #if
tests the value of a defined macro and #ifdef tests for its
existence.  In all code I have seen (I have lots of source to
packages which I use) written to support several different compilers,
the test always made is the #ifdef test.

By the way,
	#define __STDC__	/* evaluates  __STDC__ = 0  */
while
	#define __STDC__  1	/* evaluates  __STDC__ = 1 */

You will only get the #if test to be true if the macro IS DEFINED
and IS DEFINED TO BE NON-ZERO.

Hope this helps.



	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

        uunet!megatek!hollen       or  hollen at megatek.uucp



More information about the Comp.lang.c mailing list