加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 19:15:47 所属栏目:百科 来源:网络整理
导读:不查看我的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++ standar
不查看我的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.

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

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

解决方法

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

使用-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 ...

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读