免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1418 | 回复: 1
打印 上一主题 下一主题

[Linux] arm-linux-gcc 4.4.3 hashtable问题(内附3.4.1) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-12-28 12:56 |只看该作者 |倒序浏览
各位大侠:
    最近在做嵌入式开发。
    原来的交叉编译环境是arm-linux-gcc 3.4.1,源码如下:
Test.h
  1. #ifndef _TEST_
  2. #define _TEST_

  3. #include <hashtable.h>

  4. class Test{
  5. public:
  6.         Test();
  7.         ~Test();

  8. private:
  9.         typedef struct {
  10.                 int nKey;
  11.         }KeyNode;
  12.        
  13.         typedef int (* HASHER)(int);
  14.         typedef int (* EXTRACTOR)(KeyNode);
  15.         typedef bool (* EQUALFUNC)(int, int);

  16.         typedef hashtable<KeyNode, int, HASHER, EXTRACTOR, EQUALFUNC> _CONN_HASH;

  17.         static int hasher(int key) { return key; }
  18.         static int extractor(KeyNode val) { return val.nKey; }
  19.         static bool equalkey(int key1, int key2) { return key1 == key2; }

  20.         _CONN_HASH* m_pConnHash;
  21. };

  22. #endif

复制代码
Test.cpp
  1. #include "Test.h"

  2. Test::Test()
  3. {
  4. }

  5. Test::~Test()
  6. {
  7. }
复制代码
在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。不胜感激

论坛徽章:
0
2 [报告]
发表于 2012-12-29 21:10 |只看该作者
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 好新的标准.貌似哪里看到过就是重写了,原来的头文件还在,但是名字冲突的,即换用了 这个名字 无序映射
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP