__STDC__ and non-strictly conforming ANSI C compilers

Jerry Schwarz jss at hector.UUCP
Sat Dec 17 07:47:18 AEST 1988


In article <9198 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) 
presents a sample of some code

>	#if __STDC__
>		#if _BRAIN_DAMAGED
>			typedef __far void *far;
>		#else
>			typedef void *far;
>		#endif
>		extern far gcalloc(size_t size, far *handle);
>	#else
>	#	if _BRAIN_DAMAGED
>			extern far char *gcalloc();
>	#	else
>			extern char *gcalloc();
>	#	endif
>	#endif

This is conforming (it may work on some conforming compilers) but not
strictly conforming. It will fail on a conforming compiler that
defines _BRAIN_DAMAGED  and doesn't like __far.  A conforming
compiler is entitled to behave this way because you're stepping on
its reserved namespace.

I'd prefer to write something like the following strictly conforming
code.

#if BRAIN_DAMAGE1
	/* stuff to set up for one kind of brain damage */
#elif BRAIN_DATAGE2
	/* stuff for another kind of braindamage. */
#else
	/* This is the only code a conforming compiler will ever see */
	typedef void* far ;
#endif

Jerry Schwarz
AT&T Bell Labs, Murray Hill

I usually don't add a disclaimer, because I think they are redundant.
But the message I'm replying to took a gratuitous swipe at AT&T.  So
for the record:  These are my opinions.  I am not a member of the
department responsible for AT&T's C compilers.



More information about the Comp.std.c mailing list