Skip to content

Commit 1c602c5

Browse files
authored
[libc] Define away __restrict in C++ without GNU extensions (llvm#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++
1 parent 2c68227 commit 1c602c5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libc/include/__llvm-libc-common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#undef __END_C_DECLS
1818
#define __END_C_DECLS }
1919

20+
// Standard C++ doesn't have C99 restrict but GNU C++ has it with __ spelling.
21+
#undef __restrict
22+
#ifndef __GNUC__
23+
#define __restrict
24+
#endif
25+
2026
#undef _Noreturn
2127
#define _Noreturn [[noreturn]]
2228

0 commit comments

Comments
 (0)