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.