简体   繁体   中英

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?

Wno-cpp显然直到GCC 4.6.x才被添加 - 它不是通过4.5.3版本的文档: http ://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/index 。 HTML#toc_Invoking-GCC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM