I'd like to suppress the warning Wstringop-overflow in a specific file, and I've tried to do so as follows
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
...
#pragma GCC diagnostic pop
But this fails to suppress the warning, which still shows up in the compilation output as ... warning: ... [-Wstringop-overflow=]
The = indicates that the warning takes an argument, but there is also a version that doesn't ([-Wstringop-overflow]), and I'm guessing that what I'm doing is suppressing the latter, not the former.
I've also tried to suppress the warning by adding the option -Wno-stringop-overflow, but I'm not sure how to do that in just one file. The following fails, since Wno-stringop-overflow is not a legal identifier:
#define Wno-stringop-overflow
What am I doing wrong here? How can I suppress all warnings of the form [-Wstringop-overflow=] in one specific file?
EDIT: I got the reasonable suggestion to provide a minimal reproducible example, so I'll do my best. This warning appears in a larger project, when building that project as a whole - it fails to appear when I compile the file in question separately. Neither was I able to create a minimal example to reproduce this particular warning. But I can provide the following example:
switch (true) {
default:
break;
}
This produces the warning -Wswitch-bool (which takes no arguments). Compiling with -Wall is enough to make this warning appear.
I am able to suppress this warning via #pragma GCC diagnostic ignored "-Wswitch-bool", but then my question is: How do I activate -Wno-switch-bool in order to suppress this warning in only the file in question, via a preprocessor directive? Again,
#define Wno-switch-bool
Doesn't work.