GCC/clang warning incompatibility with unused private member variables

Jonathan Wakely jwakely@redhat.com
Fri Jun 11 22:14:47 GMT 2021


Here's another #pragma solution to your problem:

class Test {
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpragmas" // so GCC ignores next line
# pragma GCC diagnostic ignored "-Wunused-private-field"
     int a_;
# pragma GCC diagnostic pop
     void b() {};
};

First tell GCC not to warn about the warning option that it doesn't
recognize, then use that option to tell clang to not warn about the
unused member.




More information about the Gcc mailing list