TURBO-C AND LINT ?
Jim Patterson
jimp at cognos.UUCP
Wed Apr 11 03:58:41 AEST 1990
In article <90033012502875 at masnet.uucp> david.megginson at canremote.uucp (DAVID MEGGINSON) writes:
>alawrenc at sobeco.com writes:
>>If you want the code you are developing to be portable to non-ANSI
>>compilers use the following macro:
>>
>> #ifdef ANSI_style
>>
>Whoa, let's not get non-standard already. Why use
>
> #ifdef ANSI_style
>
>instead of the ANSI standard
>
> #ifdef __STDC__
>
>which all strict ANSI compilers should define automatically?
Using your own symbol instead of __STDC__ isn't non-standard, and
there are good reasons for avoiding scattering #ifdef __STDC__ all
through a large product. Sure, all strict ANSI compilers will define
__STDC__. However, a really strict ANSI compiler won't define __STDC__
if it's compiling in a mode that isn't strictly ANSI (e.g. if stdio.h
defines some externals that aren't in the ANSI standard; that's
namespace polution). What's more, it won't let YOU define __STDC__
(it's reserved). This doesn't mean that it won't support prototypes.
(Yes, there are such compilers).
There is also the converse problem. Some not-fully-ANSI compilers
define __STDC__, but to be some other value e.g. 0. It's conceivable
that a compiler vendor might define __STDC__ but might not support
prototypes, or they might have a bug which prevents their use. After
all, ANSI can't proscribe the actions of compiler venders who don't
support the ANSI standard (though there's a pretty wide concensus that
such vendors are being quite anti-social).
So, using your own manifest name instead of __STDC__ is a good idea.
If your project has a common #include file as many do, then you can
#define your manifest there based on __STDC__ or whatever else
is appropriate, e.g.
#ifdef __STDC__
#if __STDC__ == 1
#define ANSI_style
#endif
#endif
--
Jim Patterson Cognos Incorporated
UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707
PHONE:(613)738-1440 3755 Riverside Drive
Ottawa, Ont K1G 3Z4
More information about the Comp.lang.c
mailing list