git: 3cdb6c9d92ec - main - libc++ inttypes.h: define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 23 Jan 2026 17:33:33 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=3cdb6c9d92ecf479a0df338267f3f844ef6feeb2
commit 3cdb6c9d92ecf479a0df338267f3f844ef6feeb2
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-01-23 17:31:53 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-01-23 17:33:23 +0000
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
---
contrib/llvm-project/libcxx/include/inttypes.h | 11 +++++++++--
1 file 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>