Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

goldsword

Error: LNK2005 in VB6 (muitiple definitions)

This topic is 5757 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, when I declare globals I get the LNK2005 error in Visual C++ 6.0, why? For example, the following code will give me this error. // a.h #ifndef __header_a #define __header_a #include "someheader1.h" #include "someheader2.h" struct MyStruct { int x,y,z; }; extern MyStruct g_Struct; #endif // b.h #ifndef __header_b #define __header_b #include "a.h" // get the g_Struct #include "someheader1.h" #include "someheader2.h" g_Struct.x = 25; #endif // main.cpp #include "a.h" #include "b.h" int main() { g_Struct.y = 25; return 0; } DEBUG_WINDOW: Error: LNK2005 4@£43g_Struct$£@£$£@$@ - Already defined in main.obj etc etc What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Error: LNK2005 4@£43g_Struct$£@£$£@$@ - Already defined in main.obj

says it all.

I bit new to this but I''ll have a go


move this g_Struct.x = 25; to the main

int main()
{
g_Struct.y = 25;
g_Struct.x = 25;
return 0;
}



should work.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!