Here's how it *should* work in userland:

1) The compiler defines __STDC__ to 1.

2) The compiler defines __STDC_HOSTED__ to 1.

3) The compiler defines __STDC_VERSION__ according to the requested
language version:

iso9899:1990, c89, gnu89: not defined (equivalent to 0)
iso9899:199409: 199409L
iso9899:1999, c99, gnu99: 199901L

The default language version for gcc is gnu89.

4) The compiler defines __STRICT_ANSI__ to 1 if the requested language
version was iso9899:1990, c89, iso9899:199409, iso9899:1999 or c99.
Otherwise, __STRICT_ANSI__ is not defined.

5) Any macro, type, variable or function defined by the C standard
should be visible if and only if __STDC_VERSION__ is greater than or
equal to the value that corresponds to the version of the standard
where that macro, type, variable or function was introduced.

6) The application defines _POSIX_SOURCE or _POSIX_C_SOURCE to indicate
that it uses macros, types, variables or functions defined in a
specific version of the IEEE 1003 (POSIX) standard. Note that
_POSIX_C_SOURCE overrides _POSIX_SOURCE. Defining _POSIX_SOURCE to
any value is equivalent to defining _POSIX_C_SOURCE to 1. Currently
defined values of _POSIX_C_SOURCE are:

IEEE 1003.1-1990: 1
IEEE 1003.1b-1993: 199309L
IEEE 1003.1c-1995: 199506L
IEEE 1003.1-2004: 200112L

Any macro, type, variable or function defined by IEEE 1003 should be
visible if and only if _POSIX_C_SOURCE is greater than or equal to
the value that corresponds to the version of the standard where that
macro, type, variable or function was introduced.

7) The application defines _XOPEN_SOURCE to indicate that it uses
macros, types, variables or functions defined in a specific version
of the X/Open Single Unix Specification. Note that the SUS was a
superset of POSIX, until the SUSv3, which is equivalent to IEEE
1003.1-2001. Currently defined values of _XOPEN_SOURCE are:

XPG3: 3
XPG4 / SUS: 4
SUS2: 500
SUS3: 600

Any macro, type, variable or function defined by the SUS should be
visible if and only if _XOPEN_SOURCE is greater than or equal to the
value that corresponds to the version of the standard where that
macro, type, variable or function was introduced.

8) Anything *not* defined in any of the above standard should be placed
in separate header files, or made visible only if the application
defines a specific macro. For instance, in glibc, getopt_long() is
visible if and only if the application defined _GNU_SOURCE, and
gethostname() is visible if and only if the application defined
_BSD_SOURCE.

9) The default behavior (if the compiler does not define __STRICT_ANSI__
and the application does not define any of the _FOO_SOURCE macros)
should be to act as if the application had defined all the
_FOO_SOURCE macros to the highest value possible, i.e. make
everything visible.

DES
--
Dag-Erling Smørgrav - des@des.no
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/lis...reebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"