Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linker error

Status
Not open for further replies.

cppdev

Programmer
May 12, 2003
23
US
How can i fix this error? I am confused about what it means.

[Linker Warning] Public symbol '_FieldDefinition' defined in both module C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\RECEIPTGENERATOR\UNIT1.OBJ and C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\RECEIPTGENERATOR\UNIT2.OBJ


Thanks in advance.

cppdev
 
I have tried including header file "unit2.h" in unit1.cpp and tried including it in in unit1.h (just including it in one file at a time) and i still get the same error.

I believe since i am including the file "unit2.h" (where FieldDefinition is defined as a class) it defines this variable 2 times in the project.

I need the variable in both .cpp files how can i do this?


Thanks,
cppdev
 
Try the "extern" for that variable in one of the .cpp files. It should do the job :)
 
Good point.

shouldnt the syntax be :

extern FieldDefinitionObject FieldDefinition;

where FieldDefinitionObject is the Class defined in unit2.h .


and just put the above "extern" statement in unit1.cpp or unit1.h ?


It keeps telling me FieldDefinition is not defined yet.



 
It seems i was wrong about the use of "extern".

should I put the keyword "extern" before the definition of the class, and put this class definition in a seperate header file ( global.h ) and put "#include "global.h" in both unit1.cpp and unit2.cpp ?

 
I shooting in the dark here but can you use a namespace in this case?


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top