git: dfc7e0631d08 - stable/14 - libc++ inttypes.h: define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 Jan 2026 08:41:51 UTC
The branch stable/14 has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=dfc7e0631d08cc884c2386228b9707c9e0c9d4d2
commit dfc7e0631d08cc884c2386228b9707c9e0c9d4d2
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-01-23 17:31:53 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-01-26 08:33:02 +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
(cherry picked from commit 3cdb6c9d92ecf479a0df338267f3f844ef6feeb2)
---
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>