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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8280320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:33:33  来源:igfitidea点击:

Where is this backward_warning.h #warning coming from?

c++xcodecompiler-warningsdeprecated

提问by Piku

Without looking through every single source file in my XCode project, is there a way to find out which #include is triggering the following warning?

无需查看我的 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.

Clicking on the error in XCode just opens the backward_warning.h file, which is totally useless.

点击XCode中的错误只是打开了backward_warning.h文件,完全没用。

I know what the warning means, I know how to fix it (when I see the file in question and can look at its #includes)... but I just don't know how to find the file causing the error!

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

回答by Michael Burr

Use the -Hoption to GCC - that will list the header files that are being included (along with a nesting indication so you can see what file is including which header).

使用-HGCC 选项 - 这将列出包含的头文件(连同嵌套指示,以便您可以查看包含哪个头的文件)。

With -Hthe error will be placed in the output stream clearly showing how the compiler got to backward_warning.h.

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

For example, when I include hash_map, I'd see:

例如,当我包含时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 ...

As an aside, /showIncludesperforms the same function in MSVC.

/showIncludes顺便说一句,在 MSVC 中执行相同的功能。

回答by Jonathan Leffler

As you stated, the file /usr/include/c++/4.2.1/backward/backward_warning.hcontains the text you quote. The headers which include backward_warning.hare:

正如您所说,该文件/usr/include/c++/4.2.1/backward/backward_warning.h包含您引用的文本。包括的标题backward_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/strstream
  • /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
  • /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/strstream
  • /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

Therefore, the code you are compiling must be including a header such as:

因此,您正在编译的代码必须包含一个标头,例如:

#include <vector.h>

instead of the preferred:

而不是首选:

#include <vector>

And the compiler is getting fussy about it. The fix is to find the code which includes the pre-standard header and update it to use the standard header.

编译器对此越来越挑剔。修复方法是找到包含预标准标头的代码并将其更新为使用标准标头。

(You get similar warnings about deprecated functions if you compile git- the functions are the SHA1 functions from OpenSSL. It is a nuisance, to be polite about it.)

(如果您编译,您会收到关于不推荐使用的函数的类似警告git- 这些函数是来自 OpenSSL 的 SHA1 函数。这是一个令人讨厌的问题,礼貌地说。)

回答by 111111

You have an old style header somewhere.

您在某处有一个旧样式的标题。

something like this

像这样的东西

IE:

IE:

#include <iostream.h>  //instead of <iostream>
#include <stdlib.h>    //instead of <cstdlib>
#include <stdio.h>    //instead of <cstdio>

if it is included from a library then I think you are SOL, I personally wouldn't rummage through a library to get it to work you will have to up date them to use namespaces. and other such.

如果它是从库中包含的,那么我认为您是 SOL,我个人不会翻阅库以使其正常工作,您将不得不更新它们以使用名称空间。和其他这样的。