I am looking for a way to suppress all possible warnings that I can get with Gcc with pragma directives. I made some protective macros that helped me disconnect third-party headers from warnings, and so far they work like a charm for msvc and clang. I still lack the correct way to use the Gcc diagnostic pragmas to suppress every warning in a section. Let me give you some examples:
In msvc we can do this:
#pragma warning(push, 0) // Code that produces warnings... #pragma warning(pop)
And in clang we can do this:
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wextra"
And the code in the middle is now disconnected from warnings forever.
And in Gcc, we also have similar pragma directives with clang, and I thought I could try something like this:
#pragma GCC diagnostic push #pramga GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra"
But passing -Wall and -Wextra in a diagnostic ignored pragma in GCC does not work like clang and does not disable all possible warnings. Instead, a special warning is sent to disable the operation:
#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" void foo (int x)
So the only workaround I can make so far is to create a long list with all the GCC warnings and use them as mentioned above. Is there a more elegant solution? If not, where can I get a complete list of Gcc alerts (preferably on an equal list)?
c ++ gcc warnings pragma
Fr0stbit
source share