[libc-commits] [libc] [libc] Define away __restrict in C++ without GNU extensions (PR #114655)
via libc-commits
libc-commits at lists.llvm.org
Sat Nov 2 02:35:11 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Roland McGrath (frobtech)
<details>
<summary>Changes</summary>
The C99 restrict keyword is spelled __restrict in the libc
headers so it can be parsed by C++ compilers with GNU extensions
that recognize it. When GNU extensions are not available in C++
---
Full diff: https://github.com/llvm/llvm-project/pull/114655.diff
1 Files Affected:
- (modified) libc/include/__llvm-libc-common.h (+6)
``````````diff
diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index 3af0b08e9e8668..e0e29bbbd5f87c 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -17,6 +17,12 @@
#undef __END_C_DECLS
#define __END_C_DECLS }
+// Standard C++ doesn't have C99 restrict but GNU C++ has it with __ spelling.
+#undef __restrict
+#ifndef __GNUC__
+#define __restrict
+#endif
+
#undef _Noreturn
#define _Noreturn [[noreturn]]
``````````
</details>
https://github.com/llvm/llvm-project/pull/114655
More information about the libc-commits
mailing list