Chris Mansley
Chris Mansley

Reputation: 782

How do I disable #warning message in 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?

Upvotes: 4

Views: 1791

Answers (1)

Michael Burr
Michael Burr

Reputation: 340416

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

Upvotes: 9

Related Questions