473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

multiple definition problem

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
Jul 23 '05 #1
2 3253
Christian Christmann wrote:
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
Jul 23 '05 #2
On 2005-06-01, Christian Christmann <pl*****@yahoo.de> wrote:
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,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jochen Zeischka | last post by:
Hi everybody! I have a question concerning code organisation. Suppose I have the following header file: #ifndef SOME_NAME #define SOME_NAME namespace N { void F()
11
by: Georg Teichtmeister | last post by:
Hello! We are developing a math - library for realtime applications and want to use some given mathlibraries as base(ipp, MTL, .. ). Our library is a wrapper for those and you should be able to...
9
by: lbj137 | last post by:
I have two files: A.c and B.c. In both files I define a global variable, int xxxx; When I compile with a green hills compiler (and also i think with a GNU compiler) I get no errors or warnings....
2
by: kai | last post by:
Hello, I wrote a little c++-program (hallo world) and I wanted to compile and link this. my steps: 1. set GCC_EXEC_PREFIX=J:\Software\WinProgs\cyggnu\h-i386-cygwin32\lib\gcc-lib\
11
by: lars.uffmann | last post by:
Easily described problem: Using g++ version 3.3.5 under suse 9.3, bla.h: ----------- #ifndef myTEST #define myTEST ZFSInt test; #endif
3
by: Student | last post by:
Hi all, While compiling a program I had this message : tools.o(.data+0x0): multiple definition of `VAR_1' main.o(.data+0x0): first defined here tools.o(.data+0x4): multiple definition of...
3
by: Jens Müller | last post by:
I have a file here with several enums: #ifndef PLANARSEP_OPTIMIZE_H #define PLANARSEP_OPTIMIZE_H enum fund_cycle_behavior_t {PASS_MODE_FIRST, PASS_MODE_BEST, PASS_MODE_ALL};
10
by: zfareed | last post by:
Similar problem to the previous post. I have created a project with about 7 files including 3 header files and 3 implementation files. I am getting a multiple definition error when compiling for...
3
by: Antonio Rivas | last post by:
Hello all. I've got a problem of multiple definition in a program that at first glance looks correct (I won't type the whole code, just the relevant one and as examples since seems is a linkage...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.