Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i have a variable
C++
char buf_temp[10];

It is defined global in a.cpp file and in b.cpp i am using
C++
extern char buf_temp[10];

But when i compile the code i get and error that :-
b.obj : error LNK2005: "char * data" (?data@@3PADA) already defined in a.obj

Why is it so?
How to remove it?
Posted

buf_temp is probably not your problem, the linker is reporting multiple instances of char * data.

Best regards
Espen Harlinn
 
Share this answer
 
That should work fine. Make sure you put the definition char buf_temp[10] into a.cpp and put the extern declaration to a.h. Then you should include a.h everywhere you use the stuff.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900