diff options
author | João Valverde <j@v6e.pt> | 2023-10-26 23:15:47 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-10-27 16:30:00 +0000 |
commit | 1a8e1b14669a9df6b12795fdf5e488a3e06db5f8 (patch) | |
tree | 761996c97c84e502b920957aca3cde56458ac662 | |
parent | 0d46d9a60a89b8d2fd37c91515f3c8153b5e6b99 (diff) |
Use explicit test for Clang with compiler attributes
Clang likes to pretend to be other compilers but does not implement
the full range of pragmas other compilers have. Make Clang
always use __attribute__, it should be better supported than
the alternatives, for example with clang-cl.
Do not use __GNUC__ to select Clang, it does not work with
clang-cl. Test explicitly for __clang__ instead.
Fixes #19385.
-rw-r--r-- | include/ws_attributes.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/include/ws_attributes.h b/include/ws_attributes.h index d004280e76..4446c4aec3 100644 --- a/include/ws_attributes.h +++ b/include/ws_attributes.h @@ -24,8 +24,7 @@ extern "C" { * * XXX - similar hints for other compilers? */ -#if defined(__GNUC__) - /* This includes clang */ +#if defined(__GNUC__) || defined(__clang__) #define _U_ __attribute__((unused)) #elif defined(_MSC_VER) #define _U_ __pragma(warning(suppress:4100 4189)) @@ -119,8 +118,7 @@ extern "C" { * useful for functions where not checking the result is either a security * problem or always a bug, such as realloc. */ -#if defined(__GNUC__) - /* This includes clang */ +#if defined(__GNUC__) || defined(__clang__) #define WS_WARN_UNUSED __attribute__((warn_unused_result)) #else #define WS_WARN_UNUSED |