[antlr-interest] "Multiple definition of" error messages at compilation

seweryn.dynerowicz at student.fundp.ac.be seweryn.dynerowicz at student.fundp.ac.be
Mon Apr 3 16:19:13 PDT 2006


Hello,

I discovered ANTLR about two days ago, but I have a small problem with it.

I need to write a small parser in C++. The grammar is correct, files are
recognized by it, but unfortunately I'm stuck at the most important point.
What I want is to parse a file into an avl binary tree and then give the
possibility for another part of my program to access this tree. The tree
structure is defined in a file named "avlTree.hh" along with all methods to
manipulate it.

The way I'm trying to do that is by adding an attribute :

public : AvlTree* root;

in my parser. It is modified whenever an element which has to be added to the
tree is found in the file.

Since the definition of the parser class is found in a .hpp file and the
implementation in the .cpp, I needed to define the following :

header "pre_include_cpp" {
#include <iostream>
#ifndef AVLTREE
#define AVLTREE
#include "avlTree.hh"
#endif
}

header "pre_include_hpp" {
#include <iostream>
#ifndef AVLTREE
#define AVLTREE
#include "avlTree.hh"
#endif
}

at the beginning of my "parser.g" file. But I get "multiple definition of ..."
for all methods appearing in "avlTree.hh" when I try to compile the files
generated by antlr from "parser.g" (I added the #ifndef AVLTREE ... #endif after
the first time I got this problem but it didn't solve it)

does anyone have an idea where the problem comes from ?

P.S. I tried to post this on jGuru.com forum but couldn't due to some technical
problem, sorry if this is a very simple question.

thank you.

------------------------
   Dynerowicz Séweryn
2° Maitrise Informatique
------------------------


More information about the antlr-interest mailing list