Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Nov 2008 17:42:38 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Roman Divacky <rdivacky@freebsd.org>
Cc:        current@freebsd.org
Subject:   Re: [RFC]: c99 compiled world
Message-ID:  <86r65j3535.fsf@ds4.des.no>
In-Reply-To: <86vduv3b3k.fsf@ds4.des.no> ("Dag-Erling =?utf-8?Q?Sm=C3=B8rg?= =?utf-8?Q?rav=22's?= message of "Mon, 10 Nov 2008 15:32:47 %2B0100")
References:  <20081106185512.GA33153@freebsd.org> <867i7b4qau.fsf@ds4.des.no> <20081110142134.GA39035@freebsd.org> <86vduv3b3k.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86r65j3535.fsf>