argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
377 stars 65 forks source link

clang vs gcc attributes #68

Closed iqgrande closed 3 years ago

iqgrande commented 3 years ago

Greetings:

When I compile under LLVM 11 and 12 I receive the following warning.

warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags) __attribute__((optimize(0)));

My current "fix" for this is below.

#ifdef __clang__
TREX_API TRex* trex_compile(const TRexChar* pattern, const TRexChar** error, int flags) __attribute__((optnone));
#else
#ifdef __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);
#endif
#endif

Could something like this be merged? Thank you for your help with this.

Kind regards, Anthony

tomghuang commented 3 years ago

Hi @iqgrande , appreciate that you found this issue and provide a fix for it. I will fix it today. Thanks.

tomghuang commented 3 years ago

Hi @iqgrande , I've tested the patch in my mac-mini with Clang 11. Could you please help to confirm whether it works for you or not? Thanks.

iqgrande commented 3 years ago

The patch works. Thanks for adding it so quickly! I tested on Linux both with GCC 11 and LLVM 12.