Index: lib/Headers/inttypes.h =================================================================== --- lib/Headers/inttypes.h +++ lib/Headers/inttypes.h @@ -27,8 +27,35 @@ #error MSVC does not have inttypes.h prior to Visual Studio 2013 #endif +// C99 7.8.1 Macros for format specifiers +// +// Footnote 191: C++ implementations should define these macros only when +// __STDC_FORMAT_MACROS is defined before is included. +// +// C++11 [c.files]p3: +// +// The macros defined by are provided unconditionally. +// In particular, the symbol __STDC_FORMAT_MACROS (mentioned +// in footnote 182 of the C standard) plays no role in C++. +// +// C11 removed the problematic footnotes. +// +// Work around this inconsistency by always defining those macros in C++ mode, +// so that a C library implementation which follows the C99 standard can be +// used in C++. + +# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS_DEFINED_BY_CLANG +# endif + #include_next +# ifdef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG +# undef __STDC_FORMAT_MACROS +# undef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG +# endif + #if defined(_MSC_VER) && _MSC_VER < 1900 /* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x". * This triggers format warnings, so fix it up here. */