c++ - 错误: conflicting declaration - cant a pointer be an int?

标签 c++ compiler-errors g++

我正在尝试编译一个库,在运行 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 aint wtv还是是否还有其他原因导致错误?

由于该库的作者在许多函数中使用了 Text* xint 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/

相关文章:

c++ - 二维 CUDA 中值滤波器优化

C++x0 unique_ptr GCC 4.4.4

compiler-errors - 无法编译多个 Solidity 版本

compiler-errors - 错误: Type constraint mismatch when applying the default type 'int * int' for a type inference variable [duplicate]

java - Bukkit插件编译问题

c++ - 使用 Qt5 为 ARM 交叉编译时的静态 libstdc++

c++ - 将 C++ 类及其派生类放在特定部分

C++ 实例初始化语法

c++ - ARMC6 忽略预处理器指令

c++ - 全局 const 变量的 G++ 名称修饰