Click here to Skip to main content
12,691,523 members (31,507 online)
Rate this:
 
Please Sign up or sign in to vote.
i have a variable
char buf_temp[10];

It is defined global in a.cpp file and in b.cpp i am using
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 11-Sep-12 4:58am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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

Best regards
Espen Harlinn
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100