arm-linux-gcc 4.4.3 hashtable问题(内附3.4.1)
各位大侠:最近在做嵌入式开发。
原来的交叉编译环境是arm-linux-gcc 3.4.1,源码如下:
Test.h#ifndef _TEST_
#define _TEST_
#include <hashtable.h>
class Test{
public:
Test();
~Test();
private:
typedef struct {
int nKey;
}KeyNode;
typedef int (* HASHER)(int);
typedef int (* EXTRACTOR)(KeyNode);
typedef bool (* EQUALFUNC)(int, int);
typedef hashtable<KeyNode, int, HASHER, EXTRACTOR, EQUALFUNC> _CONN_HASH;
static int hasher(int key) { return key; }
static int extractor(KeyNode val) { return val.nKey; }
static bool equalkey(int key1, int key2) { return key1 == key2; }
_CONN_HASH* m_pConnHash;
};
#endif
Test.cpp#include "Test.h"
Test::Test()
{
}
Test::~Test()
{
}
在3.4.1编译正常。
但移到4.4.3后提示错误信息如下:
arm-linux-g++ -g -Wall-DDEBUG-D_REENTRANT -shared -lpthread -L./lib -I./inc -o./lib/Test.so ./src/Test.cpp
In file included from ./src/Test.cpp:1:
./inc/Test.h:22: error: ISO C++ forbids declaration of 'hashtable' with no type
./inc/Test.h:22: error: expected ';' before '<' token
./inc/Test.h:28: error: ISO C++ forbids declaration of '_CONN_HASH' with no type
./inc/Test.h:28: error: expected ';' before '*' token
make: *** [../lib/Test.so] 错误 1
查了下,貌似说4.0版本后的hashtable操作已经过时,可也没找到个例子,哪位仁兄能帮忙解释下,或者给个demo。不胜感激 1. If missing <hashtable.h> Then include this header <tr1/unordered_map> or <tr1/unordered_set>
>http://gcc.gnu.org/gcc-4.3/porting_to.html
2. C++11
>http://gcc.gnu.org/wiki/cxx-conversion #Convert hash tables
重写了hashtable , -std=c++11
换这个头文件试试 #include<unordered_map>
曾经看到过,说是重写了,但应该不是这个呀2012年8月的版本?c++11 好新的标准.貌似哪里看到过就是重写了,原来的头文件还在,但是名字冲突的,即换用了 这个名字 无序映射
页:
[1]