From 0b91d77bf4e4ff65ebeed90acd141018d9889e0f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 17 Dec 2024 12:18:37 -0800 Subject: [PATCH] [libc] Use __attribute__((__nothrow__)) for __NOEXCEPT in C (#114653) Consistent with glibc headers, where `noexcept` is used in C++ (or `throw()` in older C++ which llvm-libc doesn't support) in the public function declarations, `__attribute__((__nothrow__))` is used in C for compilers that support it. --- 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 e0e29bbbd5f8..d54ee7b9f91f 100644 --- a/libc/include/__llvm-libc-common.h +++ b/libc/include/__llvm-libc-common.h @@ -53,7 +53,11 @@ #define __restrict restrict // C99 and above support the restrict keyword. #undef __NOEXCEPT +#ifdef __GNUC__ +#define __NOEXCEPT __attribute__((__nothrow__)) +#else #define __NOEXCEPT +#endif #endif // __cplusplus