0

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.

mrz
  • 1,802
  • 2
  • 21
  • 32
  • 2
    You wrong thinking he knows what he doing. The error says conflicting declarations, that's never right. – john Nov 18 '12 at 12:05
  • so I should change `int x` to `int smth` then, right? – mrz Nov 18 '12 at 12:07
  • 3
    Hmm. The library code is essentially full of bugs and generally horrible. The author seems to be writing it blind, without checking whether it actually compiles, and he generally seems to have no idea what he’s actually doing. Don’t use it. – Konrad Rudolph Nov 18 '12 at 12:13
  • 1
    I would change `Text* x` to `Text* text`. – john Nov 18 '12 at 12:13
  • To add to what Konrad says. Not only buggy, but also written by someone who only has limited understanding of C++. – john Nov 18 '12 at 12:15
  • I get many of the same errors in other classes, unfortunately I have to use it though, since that was the only Chinese to pinyin library in C++ I could find... but thanks anyhow – mrz Nov 18 '12 at 12:17

2 Answers2

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.

Öö Tiib
  • 10,809
  • 25
  • 44
  • yes, seems he was drunk writing it, cause I get `error: ‘strcmp’ was not declared in this scope` since he hasn't include ``... but thanks for your answer... I will accept your answer in a minute, when I'm allowed to... cheers – mrz Nov 18 '12 at 12:19
0

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

Roee Gavirel
  • 18,955
  • 12
  • 67
  • 94