cyclical dependency (?) [solved]

Started by
2 comments, last by FunLogic 16 years, 11 months ago
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?
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..
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
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.
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.

This topic is closed to new replies.

Advertisement