【发布时间】:2012-11-18 12:02:52
【问题描述】:
我正在尝试编译一个库,在运行make 时出现以下许多错误:
error: conflicting declaration ‘int x’
error: ‘x’ has a previous declaration as ‘Text* x’
代码如下:
.
.
.
class Text;
class Code {
private:
std::vector<std::string> *tokens;
std::vector<std::string> *compounds;
std::vector<std::string> *compound_xml;
std::vector<std::string> *compound_xml_action;
void set_helper(Text *x, int a, int b, int c, std::string field, std::string value);
std::string itoa(int x);
public:
Code();
~Code();
int analyse_code(Text *x, std::string c, int x, int y, int z);
int print(Text *x, std::string c, int x, int y, int z);
int is_class(Text *x, std::string c, int x, int y, int z);
int is_class2(Text *x, std::string c, int x, int y, int z);
int not_class(Text *x, std::string c, int x, int y, int z);
.
.
.
所以在analyse_code 函数\方法中,我应该将int x 转换为int a 或int wtv 还是其他原因导致错误?
由于库的作者在许多函数中使用了Text* x 和int x,我想也许他知道他在做什么并且指针可以是int,或者我认为他知道他在做什么是错误的?
无关:库是Adso,中文文本分析引擎。
【问题讨论】:
-
你错误地认为他知道自己在做什么。错误表明声明冲突,这是不对的。
-
那我应该把
int x改成int smth吧? -
嗯。库代码基本上充满了错误,而且通常很糟糕。作者似乎是在瞎写,没有检查它是否真的编译,而且他通常似乎不知道他实际上在做什么。不要使用它。
-
我会将
Text* x更改为Text* text。 -
补充康拉德所说的。不仅有问题,而且是由对 C++ 了解有限的人编写的。
标签: c++ compiler-errors g++