[libc-commits] [libc] 1c602c5 - [libc] Define away __restrict in C++ without GNU extensions (#114655)
via libc-commits
libc-commits at lists.llvm.org
Mon Nov 4 11:23:30 PST 2024
Author: Roland McGrath
Date: 2024-11-04T11:23:27-08:00
New Revision: 1c602c5fe5d0a22e9accc08fda4ea50f49938476
URL: https://github.com/llvm/llvm-project/commit/1c602c5fe5d0a22e9accc08fda4ea50f49938476
DIFF: https://github.com/llvm/llvm-project/commit/1c602c5fe5d0a22e9accc08fda4ea50f49938476.diff
LOG: [libc] Define away __restrict in C++ without GNU extensions (#114655)
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++
Added:
Modified:
libc/include/__llvm-libc-common.h
Removed:
################################################################################
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]]
More information about the libc-commits
mailing list