In C/C++ code I try to port, a deprecated system header is included:
From the header:
#ifdef __GNUC__
#warning "this header is deprecated"
#endif
As we compile here with gcc -Wall -Werror
, compilation stops.
In the long run, replacing the use of deprecated functions is best, but for now I want to disable just this warning.
Compiling without -Werror
of course works, but as this is part of a completely automated build process, I prefer not to do that.
Including the header with #undef
ing __GNUC__
before and #define
ing it afterwards is a possibility, but I'm worried of the side effects inside the included header.
Is there a way to either disable #warning
or relax -Werror
just for one header?
1 : impaired or limited by a physical, mental, cognitive, or developmental condition : affected by disability. 2 : incapacitated by illness, injury, or wounds. disabled.
To disable is defined as to make something not work that was working before, or to injure someone in a way that makes them unable to do something. An example of disable is to stop a car from running by disconnecting the battery cables.
—disablement noun [countable, uncountable] —disabling adjective a disabling injury→ See Verb tableExamples from the Corpusdisable• Don had been permanently disabled in a car accident.
highly spiced; prepared with hot or piquant seasoning; deviled.
You can do this with a (GCC specific) diagnostic pragma
If you surround the include with the following it will disable any warnings caused by #warning
.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcpp"
#include "header.h"
#pragma GCC diagnostic pop
Note that if you change the ignored
to warning
in the above the compiler still prints the warnings - it just doesn't act on the -Werror
flag for them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With