home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: willcox@urbana.mcd.mot.com (David A Willcox)
-
- jwag@moose.asd.sgi.com (Chris Wagner) writes:
-
- >I am trying to figure out the feature test macro for POSIX1003.4 and 4a.
- >Although draft 12 gives lots of compile-time option constants, it seems
- >to imply that the only feature test macro is _POSIX_C_SOURCE.
- >Draft12 seems to imply that as of a certain date (the date of approval
- >I assume) all the symbols defined in POSIX1003.4 will suddenly be
- >added to header files such as stdio.h, etc. A user can optionally
- >set _POSIX_C_SOURCE to an earlier date to preclude certain symbols.
- >Is this right?? It seems kind of silly to base visibility on date.
- >I would expect that most developers will still want to be able
- >to demand a pure 1003.1 symbol environment.
- >Is this _POSIX_C_SOURCE just a 1003.4 hack? or has it been
- >formally adopted at the way the future POSIX stds will
- >be added to existing headers.
-
- A short tutorial on POSIX feature test macros ...
-
- 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. Basically, if the
- application defines a feature test macro, it is saying that it "knows"
- about, and is willing to deal with, the additions to the name space
- that are associated with that feature test macro.
-
- _POSIX_C_SOURCE is the new POSIX method for controling visibility of
- POSIX symbols. The application sets _POSIX_C_SOURCE to a date value,
- and that PERMITS the implementation to make visible any symbols
- associated with parts of POSIX that were approved on or before that
- date. (Using a date as the value is arbitrary. A simple integer that
- was incremented with each new revision could have been used, but we
- felt that a date would be more meaningful to humans.) The
- implementation then informs the application which options it actually
- supports through version macros (e.g. _POSIX_VERSION and
- _POSIX2_C_VERSION), or specific "feature present" macros (e.g.
- _POSIX_SYNCHRONIZED_IO).
-
- So, if an application only wants to see only POSIX.1 ("POSIX Classic"),
- then it will define _POSIX_SOURCE. Only symbols defined in IEEE
- Std 1003.1-1990 (or -1988) will appear, even if the implementation
- supports POSIX.2, POSIX.4, and ten other options that haven't been
- created, yet. An application that needs POSIX.1 and POSIX.2 Annex B
- will define _POSIX_C_SOURCE to 199208L [exact value not yet
- determined], and POSIX.4 symbols will not appear. An application that
- wants only POSIX.4 will define _POSIX_C_SOURCE to 199209L [again,
- exact value not yet determined], and the implementation is then
- permitted to make visible symbols from POSIX.1, POSIX.2, and POSIX.4.
-
- A couple of things to note:
- (1) Just because the application sets _POSIX_C_SOURCE to a value, does
- not mean that the imlementation supports all of the requested
- options. If the application sets _POSIX_C_SOURCE to 199209L
- [using the above example] but the implementation doesn't support
- POSIX.4, then clearly POSIX.4 symbols might or might not appear.
- (2) There is no way for an application to say "I want POSIX.4 symbols
- but NOT POSIX.1 or POSIX.2 symbols. It doesn't need to use the
- unwanted options, but it must respect the reserved namespace of all
- options defined before
- (3) It is our hope that the IEEE will publish a table saying "here are
- the symbols defined if <header.h> is included and _POSIX_C_SOURCE
- is set to yyyymmL" whenever a new revision is approved.
- (4) If this was all consistent, defining _POSIX_C_SOURCE as 199009L
- would be equivalent to defining _POSIX_SOURCE. Unfortunately,
- that isn't required by the current version of POSIX.1.
-
- >It seems to me that each standard should add feature test macros that
- >can be defined at compile time...(e.g. _POSIX_4SOURCE, etc.)
-
- The feature test macros are defined at compile time, it's just that
- there is only one feature test macro instead of many.
-
- Something that many people don't understand is that the different
- POSIX.* docuements are not different standards. POSIX.2 Annex B,
- POSIX.4, POSIX.4a, POSIX.1a, plus several others, are revisions of
- POSIX.1 describing optional features. Ultimately, they are all
- considered part of one ISO standard, 9945-1. (Somebody will probably
- correct me on this, but 9945-2 is shell and utilities [most of POSIX.2],
- and 9945-3 is system administration.) So it actually makes more sense
- for all of the C bindings to use the same feature test macro than to
- give each option of the standard its own feature test macro.
-
- David A. Willcox "Just say 'NO' to universal drug testing"
- Motorola MCG - Urbana UUCP: ...!uiucuxc!udc!willcox
- 1101 E. University Ave. INET: willcox@urbana.mcd.mot.com
- Urbana, IL 61801 FONE: 217-384-8534
-
-
- Volume-Number: Volume 27, Number 96
-
-