gpt4 book ai didi

c++ - 类函数和命名空间之间重新声明的符号

转载 作者:太空宇宙 更新时间:2023-11-04 11:49:37 24 4
gpt4 key购买 nike

我的 makefile 中有两个头文件。

有一个函数符号“uint32_t util::hash(const char*)”,

另一个有一个命名空间符号“namespace util::hash { }”

g++ 提示:

StringUtil.h:24: error: ‘uint32_t util::hash(const char*)’ redeclared as different kind of symbol
../util/hash/Hash_Interface.h:8: error: previous declaration of ‘namespace util::hash { }’

这两个文件来自其他库,所以我无法更改名称。如何解决?

最佳答案

您可以将其中一个头文件包含在命名空间中,例如

namespace foo
{
#include "some_file.h"
}

现在 "some_file.h" 头文件中的所有符号都在 foo 命名空间中。

关于c++ - 类函数和命名空间之间重新声明的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18896787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com