Jump to content
  • Advertisement
Sign in to follow this  
garyfletcher

problem with globals

This topic is 4886 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 a variable declared in a header file apps.h: static boost::shared_ptr<aClass> varname; I want it to be visibale through all the project files so I have it static. BUT this is causing problems with my stack. Is there ANY other way I can make this global without it being static?

Share this post


Link to post
Share on other sites
Advertisement
When you make a variable static in global scope, you effectively restrict it from beeing visible outside the file you declared it in. So, the solution to your problem is to define the variable like so:

boost::shared_ptr<aClass> varname;

in your source (.cpp) file and declare it extern like so:

extern boost::shared_ptr<aClass> varname;

in the header file.

[edit]Damn, I'm always too late [headshake][/edit]

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.

GameDev.net 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!