[libc-commits] [libc] [libc] Make headers compatible with C++ < 11 (PR #123260)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Thu Jan 16 16:20:45 PST 2025


https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/123260

C++11 introduced `noexcept`, but `throw()` can be used in older
versions of the language.


>From b3a72930753287f35b772a99c721d9d610137aa4 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Thu, 16 Jan 2025 16:19:44 -0800
Subject: [PATCH] [libc] Make headers compatible with C++ < 11

C++11 introduced `noexcept`, but `throw()` can be used in older
versions of the language.
---
 libc/include/__llvm-libc-common.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index c63eb134a5e5d7..b5a23c5765f4d8 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -39,7 +39,11 @@
 #define _Thread_local thread_local
 
 #undef __NOEXCEPT
+#if __cplusplus >= 201103L
 #define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT throw()
+#endif
 
 #else // not __cplusplus
 



More information about the libc-commits mailing list