Skip to content

Commit

Permalink
fix: Clang doesn't recognize GCC attribute
Browse files Browse the repository at this point in the history
In GCC, we use __attribute__((optimize(0))) to turn off compiler
optimization. However, in Clang we should use optnone instead of
optimize(0).

closes: #68
  • Loading branch information
tomghuang committed Jun 12, 2021
1 parent 0652e9a commit 7704006
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/arg_rex.c
Expand Up @@ -96,7 +96,9 @@ typedef struct {
int len;
} TRexMatch;

#ifdef __GNUC__
#if defined(__clang__)
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags) __attribute__((optnone));
#elif defined(__GNUC__)
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags) __attribute__((optimize(0)));
#else
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags);
Expand Down

0 comments on commit 7704006

Please sign in to comment.