这个backward_warning.h #warning来自哪里?

Pik*_*iku 6 c++ xcode deprecated compiler-warnings

不查看我的XCode项目中的每个源文件,有没有办法找出哪个#include触发了以下警告?

#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 <X> header for the <X.h> 
header for C++ includes, or <iostream> instead of the deprecated header 
<iostream.h>. To disable this warning use -Wno-deprecated.
Run Code Online (Sandbox Code Playgroud)

单击XCode中的错误只会打开backward_warning.h文件,这完全没用.

我知道警告意味着什么,我知道如何解决它(当我看到有问题的文件并且可以查看它的#includes)...但我只是不知道如何找到导致错误的文件!

Mic*_*urr 11

使用-HGCC选项 - 将列出正在包含的头文件(以及嵌套指示,以便您可以查看哪个文件包含哪个头).

随着-H该错误将被放置在输出流中清楚地显示出编译器如何到达backward_warning.h.

例如,当我包括时hash_map,我会看到:

mikeb@ubuntu:~$ g++  -H -c test.cpp
. /usr/include/c++/4.4/backward/hash_map
.. /usr/include/c++/4.4/backward/backward_warning.h
In file included from /usr/include/c++/4.4/backward/hash_map:60,
                 from test.cpp:3:
/usr/include/c++/4.4/backward/backward_warning.h:28: warning: #warning This file
includes at least one deprecated or antiquated header which may be removed without
further notice at a future date. Please use a non-deprecated interface with equivalent 
functionality instead. For a listing of replacement headers and interfaces, consult 
the file backward_warning.h. To disable this warning use -Wno-deprecated.

... a bunch of snipped output ...
Run Code Online (Sandbox Code Playgroud)

另外,/showIncludes在MSVC中执行相同的功能.

  • 那很有效.发现我有自己的'Vector.h'(基于数学的向量,而不是STL向量)编译器与STL Vector头混淆.一小段文件重命名和警告已经消失.永远不会发现只是通过查看标题为'Vector.h'是我自己的代码. (3认同)