[PATCH 1/4] include: Add macro to ignore -Wuser-defined-warnings
Tsukasa OI
research_trasio@irq.a4lg.com
Wed Sep 21 06:13:25 GMT 2022
On 2022/09/21 1:36, Nick Clifton wrote:
> Hi Tsukasa,
>
>> +# if __has_warning ("-Wuser-defined-warnings")
>
> I have not seen __has_warning () before. Is this a new feature of
> recent GCCs and Clang, or am I just behind the times ?
Nick, this is one of the Clang language extensions:
<https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros>
and already used in Binutils, include/diagnostics.h:58 (latest master)
# if __has_warning ("-Wenum-compare-switch")
This and my new line with __has_warning are surrounded by "#if defined
(__clang__)" (a Clang-only part of the code) and should not expand to a
non-zero value unless:
1. __has_warning is implemented as either a Clang extension
or a custom macro (I will not assume this for obvious reasons).
2. Builtin __has_warning (as I assumed above) detects given warning
is implemented.
__has_warning is a Clang extension but similar standard feature testing
macros with arguments are defined in recent C++ versions (not usable as
standard language features in Binutils, though):
- __has_include (C++17 or later)
- __has_cpp_attribute (C++20 or later)
Thanks,
Tsukasa
>
> Cheers
> Nick
>
More information about the Binutils
mailing list