Advertisement Jump to content


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


Global instances

This topic is 5367 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 have 3d engine with several modules. They are compiled using precompiled headers. I want to use a global instances that can be changed or used in every module. How to do this? When linking it says that instance was already defined in *.obj I am programming in C++ [edited by - kulik on May 10, 2004 11:45:52 AM]

Share this post

Link to post
Share on other sites
You don''t want to declare instances in your headers, precompiled or not. Use extern in the headers with declared pointers to engine objects. Then actually declare pointers to the engine objects in your main module, and initialize those pointers in a startup function. It''s better to use pointers to your objects rather than create global instances directly because you have better control over initialization, as well as the ability to remove certain engine components as you see fit by setting null pointers (i.e if you want a null-render), while declaring instances would mean you''re "stuck" with the components.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!