2016-04-14 40 views
0

我在我的C++應用程序中使用了hash_map。當我使用版本4.1.2構建成功的應用程序時。當我嘗試構建應用程序與4.4.6版的基礎上我看着/usr/include/c++/4.4.6/backward/backward_warning.h,改變了hash_mapunordered_map的建議是拋出誤差如何在C++ 4.4.6中包含hash_map?

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

現在我收到以下錯誤,

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

我可以在/usr/include/c++/4.4.6/c++0x_warning.h只看到錯誤消息。

我對C++相當陌生。有人可以幫助我嗎?

+1

請問您是否可以在「hash_map」中將您的更改撤消爲「unordered_map」,然後在編譯結構的末尾添加「-Wno-deprecated」(不帶引號)。看起來有些包在4.4.6中不推薦使用 –

+1

您可以使用-std = C++ 0x或-std = gnu ++ 0x編譯器選項啓用C++ 0x支持? (請注意,自從2011年標準化以來,C++ 0x現在稱爲C++ 11)。或者,您可以禁用-Wno-deprecated的第一個警告。或者你可以使用比5年前更新的編譯器版本。 – immibis

+1

您可以使用'std :: tr1 :: unordered_map'('#include ') – Praetorian

回答

1

假設您正在使用GCC(g++),請嘗試將-std=c++0x添加到您的命令行中,因爲消息說編譯器使用C++ 11。

+0

謝謝。我如何在Makefile中使用'-std = C++ 0x'。 – Dany

+0

我試着'CXXFLAGS + = -std = C++ 0x'並從'CCFLAGS + = -Werror -Wno-deprecated'中移除了'-Wno-deprecated'。我的意思是我用了'CCFLAGS + = - 錯誤CXXFLAGS + = -std = C++ 0x',但它沒有奏效。 – Dany