Skip to content

Commit

Permalink
Add an option to disable the 'restrict' keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Apr 6, 2024
1 parent 99d0a8a commit 217227d
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lite_str.h
Original file line number Diff line number Diff line change
@@ -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 <stddef.h>

/**
Expand Down

0 comments on commit 217227d

Please sign in to comment.