Skip to content

Commit

Permalink
[libc] Keep headers compatible with -std=c89 mode (llvm#121981)
Browse files Browse the repository at this point in the history
C89 doesn't have the `restrict` keyword.  When in `-std=c89`
mode, GNU-compatible compilers require the `__restrict` spelling.
  • Loading branch information
frobtech authored Jan 7, 2025
1 parent 6869425 commit ce33a48
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libc/include/__llvm-libc-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@
#define __END_C_DECLS

#undef __restrict
#define __restrict restrict // C99 and above support the restrict keyword.
#if __STDC_VERSION__ >= 199901L
// C99 and above support the restrict keyword.
#define __restrict restrict
#elif !defined(__GNUC__)
// GNU-compatible compilers accept the __ spelling in all modes.
// Otherwise, omit the qualifier for pure C89 compatibility.
#define __restrict
#endif

#undef _Noreturn
#if __STDC_VERSION__ >= 201112L
Expand Down

0 comments on commit ce33a48

Please sign in to comment.