yanyiwu / limonp

C++ headers(hpp) library with Python style.
MIT License
125 stars 43 forks source link

在-std=c++0x下使用unordered_map和unordered_set出现编译错误 #7

Closed lotusnowshen closed 9 years ago

lotusnowshen commented 9 years ago

问题出现在这里:

#if(__cplusplus == 201103L)
#include <unordered_map>
#include <unordered_set>
#else
#include <tr1/unordered_map>
#include <tr1/unordered_set>
namespace std
{
using std::tr1::unordered_map;
using std::tr1::unordered_set;
}
#endif

我使用的环境是ubuntu 12.04 LTS 编译器: gcc version 4.6.4

问题可能是#if(__cplusplus == 201103L)判断条件错误。 我采用的是-std=c++0x,于是代码中采用了TR1的版本,但是C++0x已经提供了unordered_map和unordered_set所以造成错误。

yanyiwu commented 9 years ago

不应该啊,你使用的是最新的代码吗? 我也是 ubuntu12.04 编译器是 gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

也使用了 -std=c++0x 也就是在 CMakeLists.txt 里面加了 ADD_DEFINITIONS(-O3 -Wall -g -std=c++0x)

编译没有任何问题啊。

你能贴一下更详细的报错吗

lotusnowshen commented 9 years ago

抱歉,错误无法还原了 最近尝试过好几次了,下次遇见再来贴一下吧。