error: conflicting declaration - cant a pointer be

2019-08-29 23:37发布

问题:

I am trying to compile a library, when running make I get many of the following errors:

error: conflicting declaration ‘int x’
error: ‘x’ has a previous declaration as ‘Text* x’

Here is the code:

.
.
.
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);

 .
 .
 .

so in analyse_code function\method, should I convert int x to int a or int wtv or is it smth else causing the error?

since the author of the library has used Text* x and int x in many functions, I thought maybe he knows what he's doing and pointers can be int, or am I wrong thinking he knows what he is doing?

Irrelevant: The library is Adso, a Chinese text analysis engine.

回答1:

You have two parameters named 'x' in declaration like that:

int not_class(Text *x, std::string c, int x, int y, int z);

Name one of them something else. For example:

int not_class(Text *txt, std::string c, int x, int y, int z);

The author was not very good, so beware other errors too.



回答2:

the problem is not only in analyse_code but in all the private functions. if you have the source code (.c file) I would have check it there also.

anyway you should change the Text *x to anything else such as Text *text