home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.29 / text0070.txt < prev    next >
Encoding:
Text File  |  1992-12-26  |  3.5 KB  |  73 lines

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