0

I am using hash_map in my C++ application. When I build the application with version 4.1.2 build succeeded. When I try to build the application with version 4.4.6 it is throwing error as

/include/c++/4.4.6/backward/backward_warning.h:28:2: error: #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.

Based on the suggestion I looked at /usr/include/c++/4.4.6/backward/backward_warning.h and changed the hash_map to unordered_map.

Now I am getting the following error,

/include/c++/4.4.6/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

I can see only the error message in /usr/include/c++/4.4.6/c++0x_warning.h.

I am fairly new to C++. Could someone help me with this?

Dany
  • 2,692
  • 7
  • 44
  • 67
  • 1
    Could you please undo your change in "hash_map" to "unordered_map" and then add " -Wno-deprecated" (without quotations) at the end of your compiling structure. It seems some packages are deprecated in 4.4.6 – Ahmet Apr 14 '16 at 01:29
  • 1
    You could enable C++0x support with the -std=c++0x or -std=gnu++0x compiler option? (Note that C++0x is now called C++11 since it was standardized in 2011). Or you could disable the first warning with -Wno-deprecated. Or you could use a compiler version that's newer than 5 years old. – user253751 Apr 14 '16 at 01:35
  • 1
    Instead of using `std::unordered_map` which requires C++11 to be enabled, you can use `std::tr1::unordered_map` (`#include `) – Praetorian Apr 14 '16 at 01:37
  • @immibis - I would like to use C++11 for my application. 1. Is it possible to use 4.4.6 for C++11. 2. Also I use make file to build the application. I used `-Wno-deprecated` with `CCFLAGS` like `CCFLAGS += -Werror -Wno-deprecated` . So if I want to add `C++0x` how can I use it. I am fairly new to C++. Could you help me with this? – Dany Apr 18 '16 at 07:59

1 Answers1

1

Assuming you are using GCC (g++), try adding -std=c++0x to your command line as the message says to have the compiler use C++11.

MikeCAT
  • 73,922
  • 11
  • 45
  • 70
  • Thank you. How can I use `-std=c++0x` in Makefile. – Dany Apr 18 '16 at 08:00
  • I tried to `CXXFLAGS += -std=c++0x` and removed `-Wno-deprecated` from `CCFLAGS += -Werror -Wno-deprecated`. I mean I used something like `CCFLAGS += -Werror CXXFLAGS += -std=c++0x` but it didnt work. – Dany Apr 18 '16 at 08:18