Where is this backward_warning.h #warning coming from?

江枫思渺然 提交于 2019-12-04 06:22:44

Use the -H option 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).

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

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

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, /showIncludes performs the same function in MSVC.

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

  • /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.)

You have an old style header somewhere.

something like this

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!