Question about namespaces

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Question about namespaces

Post by roxaz »

I noticed that in most examples ony one namespace is used globaly, other namespaces are written in front of functions. But using all 6 namespaces globaly is more comfortable i say. But examples are written by much better programmers than me. So is there any difference?
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I use this :

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
using namespace io;

Just because it's easier and you don't have to put the namespace prefix on everything.
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

I usually open the namespaces only in cpp files and leave all types in headers fully scoped. This way there is no danger of name collision across includes, and in the cpp file itself, this is easy to resolve.

And I never open std, but always use it explicitly. Their names are very generic and the namespace name itself is short enough, to not make this awkward.
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

aha, so there may be some name usage problems, i see now. last day i tried to use list in my project. it ended with lots of errors and no success. i gues this was std namespace problem... great that you mentioned it, thx ;)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

roxaz wrote:aha, so there may be some name usage problems, i see now. last day i tried to use list in my project. it ended with lots of errors and no success. i gues this was std namespace problem... great that you mentioned it, thx ;)
Yes, try to use all Irrlcht namespaces before #include <windows.h>... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fakin
Posts: 14
Joined: Wed Jan 24, 2007 9:02 pm
Location: zagreb, croatia

Post by fakin »

well, using all namespaces may slow down your compilation time...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

By about 0.01µs per file... ;)
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

Saturn wrote:By about 0.01µs per file... ;)
yeah well there can be many files in a final project and if you're anything like me you compile 50 times after changing one letter.

or the classic oops forgot to tweak that or change that compile again oops another thing I missed and end up compiling a million times to look at the work for less then ten seconds lol.

I use all irrlicht namespaces once globally for small projects.
Post Reply