home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!indetech!cirrus!dhesi
- From: dhesi@cirrus.com (Rahul Dhesi)
- Subject: Re: How to handle __STDC__
- Message-ID: <1992Aug31.195504.4847@cirrus.com>
- Sender: news@cirrus.com
- Organization: Cirrus Logic Inc.
- References: <393@bsovax.UUCP> <MJN.92Aug31021141@pseudo.uucp>
- Date: Mon, 31 Aug 1992 19:55:04 GMT
- Lines: 73
-
- I believe the problem is that a non-boolean situation (i.e., how
- standard-conformant a compiler is) is being indicated using a boolean
- condition. The result is like digitized sound on a home computer that
- drives the speaker with a flip-flop.
-
- ===== begin saved article =====
- Newsgroups: comp.lang.c
- From: dhesi@cirrus.com (Rahul Dhesi)
- Subject: Re: The __STDC__ That Wouldn't Die!
- Message-Id: <1991Nov27.201130.14777@cirrus.com>
- Date: Wed, 27 Nov 1991 20:11:30 GMT
-
- In <gwharvey.691197381@node_25b73> gwharvey@lescsse.jsc.nasa.gov (Greg
- Harvey) writes:
-
- >A particularly GOOD example of this is the C compiler for Apollo.
- >It is not anywhere CLOSE to fully ANSI compliant, but they have
- >defined the __STDC__ macro. It MYSTIFIES me why someone would
- >do this!
-
- Being a heretic, I think that *all* C compilers should predefine
- __STDC__. Reasoning:
-
- 1. Many careless programmers do stuff like
-
- #ifdef __STDC__
- ... some feature that works for ANSI C ...
- #endif
-
- thus making the assumption, often incorrect, that just because __STDC__
- is not defined, the feature they want is not available. The fallacious
- reasoning they are using is:
-
- (A => B) => (not A => not B)
-
-
- Such programmers need to be persuaded not to trigger code on __STDC__.
- If all compilers defined __STDC__, these programmers would learn
- quickly.
-
- A real example: A true standard C environment is not permitted to
- predefine the fileno() macro in <stdio.h>, but reasonably portable code
- can still need it. To compile such code, the user may be obliged to
- turn off the standard C environment, thus undefining __STDC__, and
- losing the many features that would be available if the code could see
- __STDC__ defined.
-
- 2. Just because __STDC__ is defined is no reason to assume that the
- compiler adheres to the letter of the standard. We already know that
- AT&T deliberately defines __STDC__ to be 0 or 1 according as the
- compiler is or is not believed to adhere to the standard. Other
- compilers (e.g. gcc) may define __STDC__ if the compiler "sort of"
- adheres to the standard and some other symbol (e..g __STRICT_ANSI__) to
- show attempted full adherence. Still others (e.g. most C compilers for
- MS-DOS) define __STDC__ even though there may be instances in certain
- "memory models", in which the compiler does not adhere to the
- standard.
-
- Since the real world is the way it is, and __STDC__ means little or
- nothing, it would be a good thing if we made it mean "nothing" rather
- than "little", so that we wouldn't need to guess which "little" it
- means.
-
- 4. A non-ANSI C compiler can define anything it wants to without
- changing its standard-conformance status.
- --
- Rahul Dhesi <dhesi@cirrus.COM>
- UUCP: oliveb!cirrusl!dhesi
- "You're even nuttier than we've come to expect of you." -- Doug Gwyn
- ===== end saved article =====
- --
- Rahul Dhesi <dhesi@cirrus.com>
- also: dhesi@rahul.net
-