home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.20 / text0133.txt < prev    next >
Encoding:
Internet Message Format  |  1990-08-02  |  3.2 KB

  1. From:  Doug Gwyn <gwyn@smoke.brl.mil>
  2.  
  3.  
  4. In article <10059@cs.utexas.edu> std-unix@uunet.uu.net writes:
  5. >>From the 1003.1 standard, 2.8.2:
  6. >    Symbols called `feature test macros' are used to control the
  7. >    visibility of symbols that might be included in a header.
  8. >    Implementations, future versions of this standard, and other
  9. >    standards may define additional feature test macros.
  10. >My interpretation of this text is that the 1003.1 committee wanted to
  11. >provide a mechanism by which a number of standards and implementations
  12. >could share the C namespace.
  13.  
  14. The feature-test macro provision was the outcome of discussions among
  15. DOnn Terry, Dave Prosser, myself, and a few others in an attempt to
  16. resolve the problem that a single implementation could not simultaneously
  17. conform to IEEE Std 1003.1 and ANS X3.159 due to the strict prohibition
  18. of the latter against implementations defining or declaring non-reserved
  19. identifiers in the standard headers.  Because of the evolutionary history
  20. of the standard headers, some of them contained both UNIX-specific and
  21. OS-independent definitions/declarations; for example, <stdio.h> included
  22. fopen(), which applies in every hosted C environment, and fdopen(), which
  23. is relevant only for UNIX-like environments.  Partly out of legitimate
  24. political concerns, X3J11 refused to allow any special dispensation for
  25. UNIX-specific extensions in the standard C headers, and as a generally
  26. appreciated service to C programmers everywhere forbid conforming C
  27. implementations to add other (non-reserved, i.e. not starting with
  28. underscore etc.) identifiers to the standard headers.  Thus, in effect
  29. other standards such as POSIX, if they are to be compatible with the C
  30. language standard, must not require implementations to define/declare
  31. such names in the headers specified in X3.159.  Yet, P1003 wished to add
  32. some of the traditional UNIX identifiers to those headers.  This is the
  33. problem that the feature-test macro POSIX_SOURCE was intended to solve.
  34. (X3J11 recommended a similar but functionally different solution.)  While
  35. they were at it, P1003 decided that packages other than 1003.1 might also
  36. benefit from feature-test macros, and ended up with the wording you saw.
  37.  
  38. The technical loophole is that any application that defines _POSIX_SOURCE
  39. has violated a constraint of X3.159, by using a reserved identifier, and
  40. this allows the implementation to act in a non-X3.159-conforming manner,
  41. in this case to define/declare otherwise-prohibited identifiers.
  42.  
  43. One drawback is that any portable 1003.1-based application that uses any
  44. of the 1003.1 extensions in standard headers will have to predefine the
  45. feature-test macro before including the headers.
  46.  
  47. There is no such problem with inclusion of headers NOT specified in
  48. X3.159.  Thus, feature-test macros can be avoided simply by specifying
  49. that new facilities be defined/declared in new add-on headers.  This is
  50. much more convenient for the programmer and is highly recommended.
  51. There is no historical-evolutionary problem for new POSIX standards,
  52. and thus there is no need for a mechanism to share the standard headers
  53. for new standards.  Instead of trying to add more cruft to standard C
  54. headers, new inventions should provide their own headers.
  55.  
  56.  
  57. Volume-Number: Volume 20, Number 131
  58.  
  59.