Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable #warning message in GCC?

Tags:

c++

c

gcc

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

A simple test case is this:

#include <iostream>
#warning "Hello"

int main() {
}

which results in this:

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

Is the documentation wrong?

like image 586
Chris Mansley Avatar asked Jan 17 '23 04:01

Chris Mansley


1 Answers

Wno-cpp apparently wasn't added until GCC 4.6.x - it's not in the docs up through those for version 4.5.3: http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/index.html#toc_Invoking-GCC

like image 156
Michael Burr Avatar answered Jan 22 '23 17:01

Michael Burr