home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2532 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.6 KB  |  49 lines

  1. Path: sparky!uunet!gatech!darwin.sura.net!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!ksr!jfw
  2. From: jfw@ksr.com (John F. Woods)
  3. Newsgroups: comp.std.c
  4. Subject: Re: <limits.h> and MB_LEN_MAX
  5. Message-ID: <15281@ksr.com>
  6. Date: 28 Aug 92 13:46:34 EDT
  7. References: <1992Aug27.165044.4781@ready.eng.ready.com>
  8. Sender: news@ksr.com
  9. Lines: 38
  10.  
  11. glenn@ready.com (Glenn Kasten) writes:
  12. ><limits.h> is supposed to define MB_LEN_MAX.  Is it permissible for a
  13. >conforming implementation to define MB_LEN_MAX in terms of another
  14. >type, where that other type is not declared in <limits.h>?  In other
  15. >words, do header files have to be complete in themselves, or can they
  16. >require other header files to also be included, in order to be
  17. >usable?
  18.  
  19. "2.2.4.2.1 Sizes of Integral Types <limits.h>
  20.  
  21.     The values given below shall be replaced by constant expressions suitable
  22. for use in #if preprocessing directives.  ...
  23.     MB_LEN_MAX"
  24.  
  25. Including <limits.h> therefore must correctly define MB_LEN_MAX.  An
  26. implementation that does not do so cannot compile this strictly conforming
  27. ANSI C program:
  28.     #include <limits.h>
  29.     main() {
  30.         int i = MB_LEN_MAX;
  31.     }
  32. and therefore is not a conforming implementation.  End of discussion.
  33.  
  34. It is acceptable for <limits.h> to perform any necessary #includes itself,
  35. ->IF<- it does so in such a way that the result of "#include <limits.h>" does
  36. not define any identifiers other than those documented in 2.2.4.2.1 or
  37. otherwise reserved to the implementation.
  38.  
  39.     BAD:
  40.     <limits.h>:
  41.     #include <screwy.h>    /* contains #define ONE 1 */
  42.     #define MB_LEN_MAX ONE
  43.  
  44.     OK:
  45.     <limits.h>:
  46.     #include <screwy.h>    /* contains #define __ONE__ 1 */
  47.     #define MB_LEN_MAX __ONE__
  48.  
  49.