Jump to content
  • Advertisement

Archived

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

QBRADQ

Splitting projects into multiple .cpp files in MSVC++ 6.0

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

How do I do this? Seems like every time I try to it returns some funky compile errors that don''t tell me much. I would love to get it set up this way to lower compile time, but I just can''t figure it out. Anyone willing to explain it a little?

Share this post


Link to post
Share on other sites
Advertisement
The compiler needs to be able to find function declarations to resolve function calls at compile time and function definitions to resolve them at linkage time. To do this, place the declarations of your data structures, global variables and functions in header (*.h, *.hpp, *.hxx) files and their definitions (initializations of globals, function bodies, etc) in source (*.c, *.cpp, *.C, *.cxx ) files.

Sharing variables can be tricky sometimes. You need to understand the concept of "ownership" - one file must "own" the variable while the rest just have permission to use it. The files which can use it should declare the variable extern (e.g. extern int i; ) while the owner declares it normally and initializes it.

I hope I''ve helped you and not confused you. It''s after 3am and I''ve been coding for 6 hours with a 1-hour interval.

Share this post


Link to post
Share on other sites
Thanks a lot! The people over at flipCode couldn''t even grasp what I was asking Thanks for that. I think this will up my productivity a lot, and the externs won''t be a problem as all my variables are in classes. I make it a point to not be allocating memory all over the place (especialy seeings how most functions in a game are iterated dosenes of times a second).

THANK YOU!

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.

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!