Jump to content
  • Advertisement

Archived

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

thedevdan

Including into a namespace.

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

If you are including a file that would clutter the global namespace, wouldn't it be a good idea to include the file into a namespace?
namespace SDL{
    #include <SDL.h>
}   
But, when I do it with iostream, it spews out tons of errors from within its files about things not being in the global namespace (becauce they use ::var a lot). Is it best not to do this? [edited by - thedevdan on May 31, 2004 2:39:19 PM] [edited by - thedevdan on May 31, 2004 2:39:50 PM]

Share this post


Link to post
Share on other sites
Advertisement
It''ll work fine with a c header such as SDL but for something like iostream it won''t. This is because (AFAIK) you can''t have nested namespaces and anyway all the iostream (and indeed all of the C++ standard libary) is in its own namespace. Why would you want to put it inside another one?

Share this post


Link to post
Share on other sites
quote:
Original post by Monder
It''ll work fine with a c header such as SDL but for something like iostream it won''t. This is because (AFAIK) you can''t have nested namespaces and anyway all the iostream (and indeed all of the C++ standard libary) is in its own namespace. Why would you want to put it inside another one?


Well, you can have nested namespaces (though you are probably talking about something else), and I wouldn''t want to do it with iostream, I was just testing it out. It didn''t work because it was trying to access members of the global namespace that weren''t there.

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!