From 217227d92d7027c66f56c70a82b8a3127361f9ab Mon Sep 17 00:00:00 2001 From: Ian Duncan <76043277+dr8co@users.noreply.github.com> Date: Sat, 6 Apr 2024 15:27:15 +0300 Subject: [PATCH] Add an option to disable the 'restrict' keyword --- lite_str.h | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lite_str.h b/lite_str.h index 2c228f5..41a8e90 100644 --- a/lite_str.h +++ b/lite_str.h @@ -1,9 +1,46 @@ #pragma once + +#if LITE_NO_RESTRICT_ + +// Ignore the warning for redefining the 'restrict' keyword +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" +#endif // __clang__ + +#define restrict + +// Restore Clang warnings +#if __clang__ +#pragma clang diagnostic pop +#endif // __clang__ +#endif // LITE_NO_RESTRICT_ + #if __cplusplus +#if !LITE_NO_RESTRICT_ // The keyword has not been redefined +#if __GNUC__ || __clang__ || _MSC_VER // Support for '__restrict' + +// Ignore the warning for redefining the 'restrict' keyword +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" +#endif // __clang__ + +#define restrict __restrict +#else // No support for '__restrict' #define restrict -extern "C" { +#endif // __GNUC__ || __clang__ || _MSC_VER + +// Restore Clang warnings +#if __clang__ +#pragma clang diagnostic pop #endif +#endif // LITE_NO_RESTRICT_ + +extern "C" { +#endif // __cplusplus + #include /**