Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 这个向后警告是从哪里来的?_C++_Xcode_Compiler Warnings_Deprecated - Fatal编程技术网

C++ 这个向后警告是从哪里来的?

C++ 这个向后警告是从哪里来的?,c++,xcode,compiler-warnings,deprecated,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 &l

如果不查看我的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.
#警告此文件至少包含一个已弃用或过时的标头。
请考虑使用第174.1.2节中发现的32个标题中的一个
C++标准。示例包括将标题替换为
C++的报头包括,或代替未标示的报头。
. 要禁用此警告,请使用-Wno弃用。
单击XCode中的错误只会打开backward_warning.h文件,这是完全无用的


我知道警告的含义,我知道如何修复它(当我看到有问题的文件并可以查看其#includes时)。。。但我只是不知道如何找到导致错误的文件

您的某个地方有一个旧式标题

像这样的

即:

#包括//而不是
#包含//而不是
#包含//而不是

如果它是从一个库中包含的,那么我认为你是索尔,我个人不会在一个库中翻来翻去让它工作,你必须更新它们才能使用名称空间。和其他类似文件。

如您所述,文件
/usr/include/c++/4.2.1/backward/backward\u warning.h
包含您引用的文本。包含
backward\u warning.h
的标题为:

  • /usr/include/c++/4.2.1/backward/algo.h
  • /usr/include/c++/4.2.1/backward/algobase.h
  • /usr/include/c++/4.2.1/backward/alloc.h
  • /usr/include/c++/4.2.1/backward/bvector.h
  • /usr/include/c++/4.2.1/backward/complex.h
  • /usr/include/c++/4.2.1/backward/defalloc.h
  • /usr/include/c++/4.2.1/backward/deque.h
  • /usr/include/c++/4.2.1/backward/fstream.h
  • /usr/include/c++/4.2.1/backward/function.h
  • /usr/include/c++/4.2.1/backward/hash_-map.h
  • /usr/include/c++/4.2.1/backward/hash_set.h
  • /usr/include/c++/4.2.1/backward/hashtable.h
  • /usr/include/c++/4.2.1/backward/heap.h
  • /usr/include/c++/4.2.1/backward/iomanip.h
  • /usr/include/c++/4.2.1/backward/iostream.h
  • /usr/include/c++/4.2.1/backward/istream.h
  • /usr/include/c++/4.2.1/backward/iterator.h
  • /usr/include/c++/4.2.1/backward/list.h
  • /usr/include/c++/4.2.1/backward/map.h
  • /usr/include/c++/4.2.1/backward/multimap.h
  • /usr/include/c++/4.2.1/backward/multiset.h
  • /usr/include/c++/4.2.1/backward/new.h
  • /usr/include/c++/4.2.1/backward/ostream.h
  • /usr/include/c++/4.2.1/backward/pair.h
  • /usr/include/c++/4.2.1/backward/queue.h
  • /usr/include/c++/4.2.1/backward/rope.h
  • /usr/include/c++/4.2.1/backward/set.h
  • /usr/include/c++/4.2.1/backward/slist.h
  • /usr/include/c++/4.2.1/backward/stack.h
  • /usr/include/c++/4.2.1/backward/stream.h
  • /usr/include/c++/4.2.1/backward/streambuf.h
  • /usr/include/c++/4.2.1/backward/stream
  • /usr/include/c++/4.2.1/backward/tempbuf.h
  • /usr/include/c++/4.2.1/backward/tree.h
  • /usr/include/c++/4.2.1/backward/vector.h
因此,您正在编译的代码必须包含标头,例如:

#include <vector.h>
#包括
而不是首选的:

#include <vector>
#包括
编译器对此越来越挑剔。解决方法是找到包含预标准头的代码,并将其更新为使用标准头


(如果您编译
git
,您会收到关于弃用函数的类似警告-这些函数是OpenSSL的SHA1函数。礼貌地说,这是一个麻烦。)

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

使用
-H
时,错误将被放在输出流中,清楚地显示编译器如何返回
warning.H

例如,当我包括
哈希映射时,我会看到:

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中执行相同的功能。

有效。我发现我有自己的“Vector.h”(用于基于数学的向量,而不是STL向量)编译器混淆了STL向量头。一点文件重命名和警告都没有了。如果只是将标题视为“Vector.h”就不会发现这是我自己的一段代码。@Piku:将其归为保留大小写但不区分大小写的MacOS文件系统。也许你可以/应该使用
\include
(或
#包括“project/Vector.h”
)机制,用于将头与系统头隔离。
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 ...