yanyiwu / cppjieba

"结巴"中文分词的C++版本
MIT License
2.6k stars 691 forks source link

bug报告:limonp/StdExtension.hpp #98

Closed archer-bao closed 1 month ago

archer-bao commented 7 years ago

该头文件下的第18行,命名空间是否写错?代码中的为“namespace std”(编译报错),修改为“namespace cppjieba”之后在个人项目中编译得以通过,请作者核查。

yanyiwu commented 7 years ago

什么编译条件下报错

archer-bao commented 7 years ago

回复楼上:为了在项目里面引入cppjieba,我把cppjieba/include/.hpp组织在一个文件夹中整合到项目中,但是DictTrie.hpp头文件包含了另外两个头文件"limonp/StringUtil.hpp"和"limonp/Logging.hpp",于是我便在包含了cppjieba/include/.hpp这些头文件的目录中建立了一个名为limonp的子目录,并且将源码limonp/*.hpp中这些头文件全部拷贝进去,在Ubuntu 16.04 x64下codeblocks中编译,但报错,报错信息为: cppjieba/limonp/StdExtension.hpp:19:17: error: ‘unordered_map’ is already declared in this scope using std::tr1::unordered_map; ^~~~~

archer-bao commented 7 years ago

编译器g++ 7.1,c++17

wangzhe258369 commented 7 years ago

这样组织头文件试试: include/cppjieba/.hpp include/limonp/.hpp

archer-bao commented 7 years ago

非常感谢楼上的回复,问题已经查明,是C++标准版本的问题,使用C++14没有问题,C++17则报错,看了一下主要问题出现在“using std::tr1::unordered_map;using std::tr1::unordered_set;”这里,推测与标准库版本tr1有关。

zhangyufei49 commented 5 years ago

我遇到了同样的问题。

环境

g++ alpine 6.4.0

解决问题的方法

cppjieba/deps/limonp/StdExtension.hpp 中 include unordered_map 部分判断平台和编译器版本的宏都去掉,使用如下代码替代

#include <unordered_map>
#include <unordered_set>
github-actions[bot] commented 1 month ago

This issue has not been updated for over 5 years and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.

github-actions[bot] commented 1 month ago

This issue has been automatically closed due to inactivity. If the issue still exists, please reopen it.