Including into a namespace.

Started by
2 comments, last by thedevdan 19 years, 10 months ago
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]
Not giving is not stealing.
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?
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.
Not giving is not stealing.
Ahh yes, of course

This topic is closed to new replies.

Advertisement