How to disable #warning message in GCC?

GCC has a pre-processor directive called #warning, which simply issues a warning at compile time with an attached string. The GCC documentation says that this can be disabled using the -Wno-cpp flag. However, this flag does not seem to be functioning. I am using GCC 4.4.3.

A simple test case:

 #include <iostream> #warning "Hello" int main() { } 

which leads to the following:

 $ g++ warn.cc warn.cc:2:2: warning: #warning "Hello" $ g++ warn.cc -Wno-cpp warn.cc:2:2: warning: #warning "Hello" 

Incorrect documentation?

+4
source share
1 answer

Wno-cpp , apparently, was not added before GCC 4.6.x - it is not in the documents before those for version 4.5.3: http://gcc.gnu.org/onlinedocs/gcc-4.5.3/ gcc / index.html # toc_Invoking-GCC

+9
source

Source: https://habr.com/ru/post/1402518/


All Articles