home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13035 < prev    next >
Encoding:
Text File  |  1992-08-31  |  3.1 KB  |  85 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!indetech!cirrus!dhesi
  3. From: dhesi@cirrus.com (Rahul Dhesi)
  4. Subject: Re: How to handle __STDC__
  5. Message-ID: <1992Aug31.195504.4847@cirrus.com>
  6. Sender: news@cirrus.com
  7. Organization: Cirrus Logic Inc.
  8. References: <393@bsovax.UUCP> <MJN.92Aug31021141@pseudo.uucp>
  9. Date: Mon, 31 Aug 1992 19:55:04 GMT
  10. Lines: 73
  11.  
  12. I believe the problem is that a non-boolean situation (i.e., how
  13. standard-conformant a compiler is) is being indicated using a boolean
  14. condition.  The result is like digitized sound on a home computer that
  15. drives the speaker with a flip-flop.
  16.  
  17. ===== begin saved article =====
  18. Newsgroups: comp.lang.c
  19. From: dhesi@cirrus.com (Rahul Dhesi)
  20. Subject: Re: The __STDC__ That Wouldn't Die!
  21. Message-Id: <1991Nov27.201130.14777@cirrus.com>
  22. Date: Wed, 27 Nov 1991 20:11:30 GMT
  23.  
  24. In <gwharvey.691197381@node_25b73> gwharvey@lescsse.jsc.nasa.gov (Greg
  25. Harvey) writes:
  26.  
  27. >A particularly GOOD example of this is the C compiler for Apollo.
  28. >It is not anywhere CLOSE to fully ANSI compliant, but they have
  29. >defined the __STDC__ macro.  It MYSTIFIES me why someone would
  30. >do this!
  31.  
  32. Being a heretic, I think that *all* C compilers should predefine
  33. __STDC__.  Reasoning:
  34.  
  35. 1.   Many careless programmers do stuff like
  36.  
  37.      #ifdef __STDC__
  38.      ... some feature that works for ANSI C ...
  39.      #endif
  40.  
  41. thus making the assumption, often incorrect, that just because __STDC__
  42. is not defined, the feature they want is not available.  The fallacious
  43. reasoning they are using is:
  44.  
  45.      (A => B) => (not A => not B)
  46.  
  47.  
  48. Such programmers need to be persuaded not to trigger code on __STDC__.
  49. If all compilers defined __STDC__, these programmers would learn
  50. quickly.
  51.  
  52. A real example:  A true standard C environment is not permitted to
  53. predefine the fileno() macro in <stdio.h>, but reasonably portable code
  54. can still need it.  To compile such code, the user may be obliged to
  55. turn off the standard C environment, thus undefining __STDC__, and
  56. losing the many features that would be available if the code could see
  57. __STDC__ defined.
  58.  
  59. 2.   Just because __STDC__ is defined is no reason to assume that the
  60. compiler adheres to the letter of the standard.  We already know that
  61. AT&T deliberately defines __STDC__ to be 0 or 1 according as the
  62. compiler is or is not believed to adhere to the standard.  Other
  63. compilers (e.g. gcc) may define __STDC__ if the compiler "sort of"
  64. adheres to the standard and some other symbol (e..g __STRICT_ANSI__) to
  65. show attempted full adherence.  Still others (e.g. most C compilers for
  66. MS-DOS) define __STDC__ even though there may be instances in certain
  67. "memory models", in which the compiler does not adhere to the
  68. standard.
  69.  
  70. Since the real world is the way it is, and __STDC__ means little or
  71. nothing, it would be a good thing if we made it mean "nothing" rather
  72. than "little", so that we wouldn't need to guess which "little" it
  73. means.
  74.  
  75. 4.   A non-ANSI C compiler can define anything it wants to without
  76. changing its standard-conformance status.
  77. -- 
  78. Rahul Dhesi <dhesi@cirrus.COM>
  79. UUCP:  oliveb!cirrusl!dhesi
  80. "You're even nuttier than we've come to expect of you." -- Doug Gwyn
  81. ===== end saved article =====
  82. -- 
  83. Rahul Dhesi <dhesi@cirrus.com>
  84. also: dhesi@rahul.net
  85.