aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2026-01-23 17:31:53 +0000
committerDimitry Andric <dim@FreeBSD.org>2026-01-23 17:33:23 +0000
commit3cdb6c9d92ecf479a0df338267f3f844ef6feeb2 (patch)
treedb5ef5f87f4d2c37eea348b50fe3c1384d1966cd
parent6c5fdba45a63d66984e15ddc6996f5e88a55f22c (diff)
libc++ inttypes.h: define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS
Before transitively including the base version of inttypes.h, define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS, because the base inttypes.h directly includes sys/stdint.h, instead of going through the 'regular' stdint.h. The libc++ version of the latter does define those macros, to ensure things like UINT64_C() and SIZE_MAX are defined even in C++98 or C++03. MFC after: 3 days
-rw-r--r--contrib/llvm-project/libcxx/include/inttypes.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/llvm-project/libcxx/include/inttypes.h b/contrib/llvm-project/libcxx/include/inttypes.h
index 8664412bd52f..501cb1c11d53 100644
--- a/contrib/llvm-project/libcxx/include/inttypes.h
+++ b/contrib/llvm-project/libcxx/include/inttypes.h
@@ -241,12 +241,19 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
# pragma GCC system_header
#endif
-/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
- for C++11 unless __STDC_FORMAT_MACROS is defined
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+ for C++11 unless __STDC_CONSTANT_MACROS, __STDC_FORMAT_MACROS
+ and __STDC_LIMIT_MACROS are defined
*/
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+# define __STDC_CONSTANT_MACROS
+#endif
#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS
#endif
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+# define __STDC_LIMIT_MACROS
+#endif
#if __has_include_next(<inttypes.h>)
# include_next <inttypes.h>