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

via libc-commits libc-commits at lists.llvm.org
Thu Jan 16 16:21:53 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/123260.diff


1 Files Affected:

- (modified) libc/include/__llvm-libc-common.h (+4) 


``````````diff
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
 

``````````

</details>


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


More information about the libc-commits mailing list