This repo describes platform headers of all kinds, and tools used to extract out information.
What would canonical headers for ISO C, POSIX, C++ etc look like? "Real" headers are full of all kinds of implementation details. Is there a place for minimal perfect headers, as a complement to standards documentation? Ones that make some implementation decisions?
This is in include/canonical
.
To emulate specific environments:
- POSIX: set
_POSIX_C_SOURCE
to an appropriate value - LINUX: define
_GNU_SOURCE
(will add more at some point) - Windows: define
_WIN32
/_WIN64
, set_WIN32_WINNT
andWINVER
to an appropriate value
What about headers you could include that would then tell you everything that the code in question is using? These are complete headers, but with output that can be scraped and coalesced to create reports.
This is in include/diagnostic
.
The same sets of knobs work on the diagnostic headers for platform emulation.
IEEE Std 1003.1 and POSIX.1 refer to the same thing. We use the latter for brevity.
Feature setting (note that this has to be manually set by the user, no compiler can infer it). Also note that all the revisions past 2008 are still identified by the same feature version.
- POSIX.1-1990:
_POSIX_SOURCE
is defined (obsolete feature macro) - POSIX.1-1990:
_POSIX_C_SOURCE
is1
- POSIX.1-1992:
_POSIX_C_SOURCE
is2
- POSIX.1-1993:
_POSIX_C_SOURCE
is199309L
- POSIX.1-1995:
_POSIX_C_SOURCE
is199506L
- POSIX.1-2001:
_POSIX_C_SOURCE
is200112L
- POSIX.1-2008:
_POSIX_C_SOURCE
is200809L
- POSIX.1-2017:
_POSIX_C_SOURCE
is200809L
- C89: ANSI X3.159-1989
- C90: ISO/IEC 9899:1990
- C95/AMD1: ISO/IEC 9899:1990/AMD 1:1995
- C99: ISO/IEC 9899:1999 N1256
- C11: ISO/IEC 9899:2011 N1570
- C17/C18: ISO/IEC 9899:2018 N2176
Feature test
- C90:
__STDC_VERSION__
has no value - C95:
__STDC_VERSION__
is199401L
- C99:
__STDC_VERSION__
is199001L
- C11:
__STDC_VERSION__
is201112L
- C18:
__STDC_VERSION__
is201710L
- C++98: ISO/IEC 14882:1998
- C++03: ISO 14882:2003
- C++11: ISO/IEC 14882:2011
- C++14: ISO/IEC 14882:2014
- C++17: ISO/IEC 14882:2017 N3797
Feature test
- C++ older:
__cplusplus
is1
- C++98:
__cplusplus
is199711L
- C++11:
__cplusplus
is201103L
- C++14:
__cplusplus
is201402L
- C++17:
__cplusplus
is201703L
Feature test (WINVER
set to same value)
- Windows NT 4.0:
_WIN32_WINNT
is0x0400
(_WIN32_WINNT_NT4
) - Windows 2000:
_WIN32_WINNT
is0x0500
(_WIN32_WINNT_WIN2K
) - Windows XP:
_WIN32_WINNT
is0x0501
(_WIN32_WINNT_WINXP
) - Windows Server 2003:
_WIN32_WINNT
is0x0502
(_WIN32_WINNT_WS03
) - Windows Vista:
_WIN32_WINNT
is0x0600
(_WIN32_WINNT_VISTA
,_WIN32_WINNT_WIN6
,_WIN32_WINNT_LONGHORN
) - Windows Server 2008:
_WIN32_WINNT
is0x0600
(_WIN32_WINNT_WS08
) - Windows 7:
WIN32_WINNT
is0x0601
(_WIN32_WINNT_WIN7
) - Windows 8:
WIN32_WINNT
is0x0602
(_WIN32_WINNT_WIN8
) - Windows 8.1:
WIN32_WINNT
is0x0603
(_WIN32_WINNT_WINBLUE
) - Windows 10:
WIN32_WINNT
is0x0A00
(_WIN32_WINNT_WIN10
,_WIN32_WINNT_WINTHRESHOLD
)
TBD we need the multiple levels of POSIX, I think. GLib has a number of levels, it looks like:
__USE_POSIX
, __USE_POSIX2
, __USE_XOPEN
, __USE_XOPEN2K8
.
Also, looks like I need one or more C++ columns. And this isn't all that helpful on its own.
Header | C90 | C99 | C11 | POSIX | GNU |
---|---|---|---|---|---|
<assert.h> | x | x | x | x | |
<complex.h> | x | x | |||
<ctype.h> | x | x | x | x | |
<fenv.h> | x | x | |||
<float.h> | x | x | x | ||
<inttypes.h> | x | 1 | |||
<iso646.h> | 2 | ||||
<limits.h> | x | x | x | ||
<locale.h> | x | x | |||
<math.h> | x | x | x | x | |
<setjmp.h> | x | x | |||
<signal.h> | x | x | x | ||
<stdarg.h> | x | ||||
<stdbool.h> | x | x | |||
<stddef.h> | x | x | |||
<stdint.h> | x | ||||
<stdio.h> | x | x | x | x | |
<stdlib.h> | x | x | x | x | x |
<string.h> | x | x | x | ||
<tgmath.h> | x | x | x | ||
<time.h> | x | x | x | x | |
<wchar.h> | 2 | x | x | ||
<wctype.h> | x | x | x |
- POSIX says
<inttypes.h>
should definewchar_t
as defined in<stddef.h>
and include the contents of<stdint.h>
. - This is really in NA1 1995.
And then everything else is in POSIX or GNU. Or Win32. Or Mac OS X or BSD.