Want the word on __STDC__

Fred Zlotnick fred at mindcraft.com
Thu Mar 7 05:40:52 AEST 1991


In article <15381 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <4203 at lupine.NCD.COM> rfg at NCD.COM (Ron Guilmette) writes:
>>I assume that you also get irrate about implementors who define __STDC__
>>to something other than 1.
>
>I have no problem with an otherwise CONFORMING implementation defining
>__STDC__ to something other than 1, although why would it?  At least
>that does not cause problems for strictly conforming applications.

But it CAN cause problems (in addition to which, such an implementation
is no longer conforming according to section 3.8.8): since we know that
nonconforming implementations do in fact sometimes define __STDC__ to
something other than 1, it would be useful to protect your code by using
the test

  #if __STDC__ == 1

rather than

  #ifdef __STDC__

This works if __STDC__ is not defined, since (according to 3.8.1) it is
"replaced with the pp-number 0".  But it won't give the desired result if
an "otherwise CONFORMING implementation" has __STDC__ defined to a value
not 1.

You could argue that nonconforming implementations are free to do whatever
they like, including defining __STDC__ to be 1.  But this would be nasty,
and in practice no intentionally nonconforming implementation is likely to
do it.
Fred Zlotnick                       |	#include <std.disclaimer>
fred at mindcraft.com                  |	#include <brilliant.quote>
...!{decwrl,ames,hpda}!mindcrf!fred |



More information about the Comp.std.c mailing list