c++ - 在 C++ 中禁用警告

标签 c++ qt warnings

我是 C++ 的新手。我正在 Qt 上编译代码源。我有这个警告:

In file included from ../ListAllPrsilicaCameras/main.cpp:3: In file included from /usr/include/c++/4.2.1/backward/iostream.h:31: /usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated. [-W#warnings]

#warning This file includes at least one deprecated or antiquated header.

^ 1 warning generated


我也收到了这些警告:

../ListCamerasProsilicaII/main.cpp:79:51: warning: unused parameter 'junk' [-Wunused-parameter]
void SetConsoleCtrlHandler(void (*func)(int), int junk)
                                                  ^
../ListCamerasProsilicaII/main.cpp:89:23: warning: unused parameter 'Signo' [-Wunused-parameter]
void CtrlCHandler(int Signo)
                      ^
../ListCamerasProsilicaII/main.cpp:140:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                        printf("%s - %8s - Unique ID = % 8lu IP@ = %15s [%s]\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCamerasProsilicaII/main.cpp:147:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o ListCamerasProsilicaII main.o   -L/opt/local/lib/ -lPvAPI -lPvJNI -L/opt/local/lib -lJPEG -F/Users/rafikgouiaa/Qt//5.0.2/clang_64/lib -framework QtCore 
                        printf("%s - %8s - Unique ID = % 8lu (unavailable, %u)\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCamerasProsilicaII/main.cpp:152:53: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                    printf("%s - %8s - Unique ID = % 8lu (*)\n",cameraList[i].SerialString,
                                                   ~^~~~
../ListCamerasProsilicaII/main.cpp:171:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
             ^
../ListCamerasProsilicaII/main.cpp:171:26: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char* argv[])
                         ^
7 warnings generated.

如何禁用此警告?

最佳答案

重复前面的回答“答案就在警告消息本身。”

"To disable this warning use -Wno-deprecated."

您可以在 Qt 项目文件 (.pro) 中添加以下行来指定编译器标志:

QMAKE_CXXFLAGS += -Wno-deprecated

附言自己修复代码会更好

关于c++ - 在 C++ 中禁用警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22716674/

相关文章:

c++ - Chrome 如何知道 Flash 何时崩溃?

c++ - 将 HeaderDoc 与 .hpp 文件而不是 .h 文件一起使用

c++ - 测试依赖于另一个类的静态函数的类

c++ - 更新不调用paintEvent?

c++ - QByteArray::right 的问题

php - 神秘的 GC 缓存条目是什么意思

c++ - C++中移动数组的函数

c++ - 在 OSX 中为 Qt 5.5 安装第三方模块

c++ - 如果没有直接包含h文件如何给出警告

php - 警告 : incorrect argument passed to function