Commit Graph

4 Commits

Author SHA1 Message Date
Michal Gorny 9eddaeb534 [include] Declare __STDC_*_MACROS for C++11 compat in old libc
Declare __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and
__STDC_CONSTANT_MACROS before including real inttypes.h/stdint.h when
the wrapper-header is included in C++11, in order to enable
the necessary macros in C99-compliant libc.

The C99 standard defined that the format macros in inttypes.h should be
defined by the C++ implementations only when __STDC_FORMAT_MACROS is
defined, and the limit and constant macros in stdint.h should be defined
only when __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined
appropriately. Following this specification, multiple old versions of
glibc up to 2.17 do not define those macros by default for C++,
rendering the libc++ headers non-compliant to the C++11 standard.

In order to achieve the necessary compliance, __STDC_FORMAT_MACROS is
defined in wrapped inttypes.h just before including the system
inttypes.h, when C++11 or newer is used. Both __STDC_LIMIT_MACROS
and __STDC_CONSTANT_MACROS are defined in newly-wrapped stdint.h. This
fixes the C++11 compliance while preserving the current behavior for
C++03.

Differential Revision: https://reviews.llvm.org/D24903

llvm-svn: 282435
2016-09-26 20:20:00 +00:00
Eric Fiselier 60506cbcd4 Cleanup foo.h headers and __config to work in C
llvm-svn: 252274
2015-11-06 06:30:12 +00:00
Richard Smith 2999ea0f04 PR25118: move system_header pragma before uses of include_next to avoid extension warnings for people finding libc++ headers via -I paths.
llvm-svn: 249788
2015-10-09 00:26:50 +00:00
Richard Smith 37df7a05c2 Split <inttypes.h> out of <cinttypes>.
llvm-svn: 249741
2015-10-08 20:38:53 +00:00