Click here to Skip to main content
11,491,598 members (73,154 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C Visual-Studio VC++
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
0 Sergey Alexandrovich Kryukov 521
1 Maciej Los 266
2 Andy Lanng 263
3 Sascha Lefèvre 245
4 OriginalGriff 165
0 Sergey Alexandrovich Kryukov 9,829
1 OriginalGriff 8,520
2 Sascha Lefèvre 3,574
3 Maciej Los 3,151
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2015
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