home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / std / unix / 460 < prev    next >
Encoding:
Internet Message Format  |  1992-11-15  |  3.9 KB

  1. Xref: sparky comp.std.unix:460 comp.std.c:3008
  2. Path: sparky!uunet!not-for-mail
  3. From: rfg@netcom.com (Ronald F. Guilmette)
  4. Newsgroups: comp.std.unix,comp.std.c
  5. Subject: Header files and "hidden built-in type hacks".
  6. Date: 15 Nov 1992 15:52:53 -0800
  7. Organization: Bug 'r us
  8. Lines: 71
  9. Sender: sef@ftp.UU.NET
  10. Approved: sef@ftp.uucp (Moderator, Sean Eric Fagan)
  11. Message-ID: <1e6nslINN4rd@ftp.UU.NET>
  12. NNTP-Posting-Host: ftp.uu.net
  13. X-Submissions: std-unix@uunet.uu.net
  14.  
  15. Submitted-by: rfg@netcom.com (Ronald F. Guilmette)
  16.  
  17. As the regular readers of comp.std.c are probably aware, there is a
  18. rather strange set of (seemingly conflicting) requirements with regard
  19. to the declaration of certain implementation-defined primitive data types
  20. and certain header files.
  21.  
  22. The most commonly cited example is the type `va_list' and the <stdio.h>
  23. header file.
  24.  
  25. Certain of the functions which must be declared (preferably with prototypes)
  26. in the <stdio.h> file (e.g. vprintf) are defined (by the ANSI C standard) to
  27. take arguments of type `va_list'.  So if these function are declared (using
  28. prototypes) within <stdio.h> it seems (at first glance) that the implementa-
  29. tion must arrange to have the type `va_list' be declared whenever <stdio.h>
  30. is included into any compilation unit.
  31.  
  32. But careful implementors know that if `va_list' is declared whever <stdio.h>
  33. is included, this will cause an small but unnecessary (and possibly illegal)
  34. pollution of the user's namespace.  Thus, careful implementors always make
  35. use of some *other* symbol (e.g. __va_list or __builtin_va_list) as the
  36. formal type given for the "va_list" type parameters in the prototyped
  37. function declarations in <stdio.h>.
  38.  
  39. I have two questions about this practice, and two follow-up observations.
  40.  
  41. My first question is simply this.  Is the practice of avoiding definition
  42. of a va_list type in <stdio.h> strictly required by the ANSI C standard?
  43. My (naive?) believe is that this practice *is* required in order to avoid
  44. non-standard pollution of the user's namespace.
  45.  
  46. My second question assumes that the answer to the first question is "yes".
  47.  
  48. My second question is also a simple one.  In what other cases are such
  49. "hidden built-in type hacks" required as a result of other requirements
  50. in the ANSI C standard (or in POSIX 1003.1-1990)?
  51.  
  52. My first observation is that it appears that another "hidden built-in type
  53. hack" (similar to the one for va_list and <stdio.h>) is also required in
  54. the case of the <time.h> file, where the ANSI C standard requires that the
  55. second formal parameter for the `strftime' function have type `size_t'
  56. even though section 4.12.1 (describing <time.h>) does not seem to permit
  57. <time.h> to define the size_t type.
  58.  
  59. My second observation is that it appears that another such case arises
  60. for those who wish to implement strict conformance with POSIX 1003.1-1990.
  61. Sepcifically, while POSIX 1003.1-1990 seems to require that <sys/types.h>
  62. be included prior to <sys/stat.h>, certain of the things which must be
  63. declared within <sys/types.h> (under the rules of POSIX 1003.1-1990) must
  64. have type `time_t' even though neither <sys/stat.h> nor <sys/types.h> are
  65. required (by POSIX) to define such a type.
  66.  
  67. (Footnote:  I know that POSIX 1003.1-1990 explicitly permits <sys/types.h>
  68. to contain additional type declarations above and beyond those which are
  69. minimally required to appear there, but there are some implementors who
  70. are fanatics about the avoidance of arbitrary implementation-dependent
  71. bits of namespace pollution, and I can well imagine that such implementors
  72. would wish to use one of these "hidden built-in type hacks" for the
  73. `time_t' type in <sys/stat.h>.  Now I just want to now if the rules permit
  74. them to do that, and if they should be encouraged to do it.)
  75.  
  76. -- 
  77.  
  78. // Ron ("Loose Cannon") Guilmette
  79. // uucp: ...uunet!lupine!segfault!rfg
  80. // New new motto:  Quality control is a state of mind.
  81. //   misc.forsale.computers ad, circa 2007:
  82. //       Used Cray wrist watch for sale; 25 bucks or best offer.
  83.  
  84.  
  85. Volume-Number: Volume 29, Number 70
  86.