multiple definition problem

  • Thread starter Christian Christmann
  • Start date
C

Christian Christmann

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
 
V

Victor Bazarov

Christian said:
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?

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
 
D

Donovan Rebbechi

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?

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

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,066
Members
47,672
Latest member
svaraho

Latest Threads

Top