I am using an inline global variable which works well for the purpose of it.
class MyClass {
public:
void Func() {
}
}
inline MyClass myClass; // global inline variable
Above works well for my purpose but I get a warning when my code compiles on gcc with compiler below C++17. Following is the warning
warning: inline variables are only available with -std=c++1z or -std=gnu++1z
Question:
How can I suppress the warning on gcc?
I tried to suppress the warning by using a #pragma
like below
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions"
inline MyClass myClass;
#pragma GCC diagnostic pop
Above #pragma
technique works on clang, but looks like GCC to not understand the #pragma
? I just want to brute force suppress the warning on GCC. How can I do that?
Looks like gcc warning options list does not even mention about this? https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
I am using gcc (GCC) 5.3.1