Jump to content
  • Advertisement
Sign in to follow this  
FunLogic

cyclical dependency (?) [solved]

This topic is 4109 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

I'm having some compiling problems due to what I 'think' is a cyclical dependency issue. I'm writing some simple straight C code, in a header file called winmain.h I have defined some globals that are used by winmain.cpp (this file obviously includes winmain.h) and wndproc.cpp (again this file includes winmain.h), it's a LNK2005 error thats telling me the objects have already been defined in winmain.obj - how can I rectify this?

Share this post


Link to post
Share on other sites
Advertisement
I'm not quite sure how you clear up some cyclical issues in C (I would assume it's similar to that of C++?)

Could I see some code? Perhaps I could help..

Share this post


Link to post
Share on other sites
It's not a cyclical definition problem. You need to declare your global variables as extern in all translation units except one, and define them in the remaining translation unit only. Your error indicates that you have defined them in all translation units.

Share this post


Link to post
Share on other sites
Quote:

It's not a cyclical definition problem. You need to declare your global variables as extern in all translation units except one, and define them in the remaining translation unit only. Your error indicates that you have defined them in all translation units.


Thanks for that! It works fine now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!