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

标签 c++ xcode compiler-warnings deprecated

在不查看我的 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 中执行相同的功能。

关于c++ - 这个 backward_warning.h #warning 来自哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8280320/

相关文章:

compiler-construction - 编译器构造

c++ - C++ 脚本语言

c++ - 模板函数 : How to make a template function with a template class as an argument?

php - 如何解析数组 PHP->JSON->XCODE 中的数组

ios - 为什么我在 xcode 中点击更新时出现错误 "No value was provided for the parameter ' certificateIds'。

c++ - `push_back` 与 `emplace_back` 标志警告

c++ - 是否有 g++ 标志可以在 switch 语句中检测并警告此无法访问的代码?

c++ - 对于双映射

c++ - 如何避免 Qt app.exec() 阻塞主线程

ios - 根据不同的设备增加启动屏幕标签的字体大小?