emilk / loguru

A lightweight C++ logging library
The Unlicense
1.77k stars 256 forks source link

Also suppress clang warnings about unknown warnings #181

Closed seanm closed 11 months ago

seanm commented 2 years ago

Without this, older versions of clang will for example warn:

loguru.cpp:21:32: warning: unknown warning group '-Wzero-as-null-pointer-constant', ignored [-Wunknown-warning-option]

pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"

                           ^
bylowerik commented 2 years ago

Why do we want to ignore these warnings?

seanm commented 2 years ago

Without this patch, old versions of clang warn on the existing line:

#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"

Because old versions don't have -Wzero-as-null-pointer-constant so they say "what's this warning you want me to disable?! there is no such warning."

An alternative is to conditionalize the diagnostic ignored statements, for clang you could do like this:

#if __has_warning("-Wreserved-identifier")
    #pragma clang diagnostic ignored "-Wreserved-identifier"
#endif

But I'm not sure about gcc....