home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: gwyn@smoke.brl.mil (Doug Gwyn)
-
- In article <v139nINNr4n@ftp.UU.NET> willcox@urbana.mcd.mot.com (David A Willcox) writes:
- >OK, here's the the way it works. An ANSI C compiler is not allowed to
- >make symbols visible to an application beyond what's defined in ANSI
- >C, unless the application does something explicit to make those
- >symbols available. The application does this by defining one or more
- >feature test macros before including any headers.
-
- More accurately: In order to conform to the C standard, a C implementation
- must, among other requirements, accept any strictly conforming C program.
- A strictly conforming C program must, among other requirements, not use
- certain classes of identifiers in contexts where they have been reserved
- for use by C implementations. And a conforming C implementation must not
- define any identifiers in the standard headers other than those specified
- in the standard plus those reserved for implementations. (Reserved
- identifiers mostly begin with underscore; see the C standard for details.)
-
- There are no requirements on any headers other than those specified in the
- standard; thus additional facilities can AND SHOULD be defined by separate
- headers, not through modifications to the standard headers. This is
- especially important when the standard C implementation is provided by
- one source of supply but the additional functionality is provided by a
- different source of supply, as frequently ocurs in this industry.
-
- The only reason there was any need for "feature flags" in the first place
- was the historical accident that some of the standard headers (notably
- <stdio.h>) included interface definitions for UNIX-specific facilities AND
- general portably-available facilities. The C standard does not single out
- the UNIX environment for an exception, but rather prohibits pollution of
- the identifier name spaces by ANY conforming implementation. Thus, for
- <stdio.h> and a few other standard headers, a conforming C implementation
- can make additional non-reserved symbols (such as "popen") visible ONLY to
- programs that are NOT strictly conforming. The method chosen by 1003.1 for
- this was for the program to somehow #define _POSIX_SOURCE before including
- the relevant standard header. This allows the implementation to key on
- that symbol to "turn on" additional symbols in the standard header, without
- those symbols being visible in the absence of such a feature flag.
-
- As the last acting liaison between X3J11 and P1003, I was heavily involved
- in getting this issue resolved. 1003.1 did not quite follow X3J11's
- recommendations, apparently adopting a different view of feature flags,
- and from what David has said I gather that the repeated message from X3J11
- to 1003 to not further pollute the standard headers has gotten lost.
-
- For NEW facilities (i.e. not those inherited from historic implementations
- of UNIX), use new, distinct headers for defining new interfaces; don't add
- new symbols (whether or not under control of feature flags) to standard C
- headers. Please!
-
-
- Volume-Number: Volume 27, Number 101
-
-