Connecting Tech Pros Worldwide Forums | Help | Site Map

multiple definition problem

Christian Christmann
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi,

I'm using "flex" which is creating a file called lex.yy.c and this
C file is added to a library. In another directory I have to use flex for
another file and also add the second lex.yy.c to another library.
Hence, I need to include both libraries and while linking I get an
e.g. "multiple definition of `yyleng'" since yyleng is created in both
lexx.yy.c.

I can't change the variable name yyleng since it's
automatically created by flex. Any idea how to solve this problem?


Thank you

Chris

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 23 '05

re: multiple definition problem


Christian Christmann wrote:[color=blue]
> I'm using "flex" which is creating a file called lex.yy.c and this
> C file is added to a library. In another directory I have to use flex for
> another file and also add the second lex.yy.c to another library.
> Hence, I need to include both libraries and while linking I get an
> e.g. "multiple definition of `yyleng'" since yyleng is created in both
> lexx.yy.c.
>
> I can't change the variable name yyleng since it's
> automatically created by flex. Any idea how to solve this problem?[/color]

If you're compiling them in C++, you could try wrapping those files in
two respective namespaces. If you're compiling them in C, then you should
ask in comp.lang.c. I know some folks actually filter those generated
modules (translation units) through a script that mangles the names just
to avoid the multiple definition problems.

Also, isn't there a lex/yacc newsgroup somewhere?

V
Donovan Rebbechi
Guest
 
Posts: n/a
#3: Jul 23 '05

re: multiple definition problem


On 2005-06-01, Christian Christmann <plfriko@yahoo.de> wrote:[color=blue]
> Hi,
>
> I'm using "flex" which is creating a file called lex.yy.c and this
> C file is added to a library. In another directory I have to use flex for
> another file and also add the second lex.yy.c to another library.
> Hence, I need to include both libraries and while linking I get an
> e.g. "multiple definition of `yyleng'" since yyleng is created in both
> lexx.yy.c.
>
> I can't change the variable name yyleng since it's
> automatically created by flex. Any idea how to solve this problem?[/color]

Did you try reading the documentation ? Take a look at the -P option.

Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
Closed Thread