我正在尝试编译一个库,在运行 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);
.
.
.
所以在analysis_code
函数\方法中,我应该将int x
转换为int a
或int wtv
还是是否还有其他原因导致错误?
由于该库的作者在许多函数中使用了 Text* x
和 int x
,我想也许他知道自己在做什么,并且指针可以是 int
,还是我错误地认为他知道自己在做什么?
无关:该库是Adso,一个中文文本分析引擎。
最佳答案
在声明中有两个名为“x”的参数,如下所示:
int not_class(Text *x, std::string c, int x, int y, int z);
将其中之一命名为其他名称。例如:
int not_class(Text *txt, std::string c, int x, int y, int z);
作者水平不太好,请注意其他错误。
关于c++ - 错误: conflicting declaration - cant a pointer be an int?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13439914/