Rename Ogre::map before official 1.7 release?

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
Calder
Greenskin
Posts: 124
Joined: Mon Mar 02, 2009 11:04 pm

Rename Ogre::map before official 1.7 release?

Post by Calder » Sat Feb 20, 2010 8:30 pm

It's only a mild inconvenience, but Ogre's map declaration interferes with STL map. This means that any files having:

Code: Select all

using namespace std
using namespace Ogre
cannot use the map class because line 497 of OgrePrerequisites.h conflicts with it. Anyway, a small nuisance but generally Ogre's pretty good about avoiding name-clashes with the STL so I thought I'd mention it.

EDIT: Just ran into the same problem with Ogre::vector. I'm going through the process of updating my code to Ogre 1.7 right now so I might keep posting these. Hopefully not though...
0 x

SigfriedMcWild
Halfling
Posts: 62
Joined: Wed Mar 03, 2004 3:12 am
Location: just a figment of your imagination
Contact:

Re: Rename Ogre::map before official 1.7 release?

Post by SigfriedMcWild » Sat Feb 20, 2010 9:51 pm

You really shouldn't be using using directives ("using namespace x;"). Using them ends up defeating the point of namespaces, as you are finding out.

In headers you should always use the fully qualified names, in source files you could use using declarations ("using x::y;") to selectively import things that you use.
0 x

User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England

Re: Rename Ogre::map before official 1.7 release?

Post by MrD » Sat Feb 20, 2010 10:19 pm

Those are there for a reason, they provide you with STL containers that default to using OGREs STL memory allocator.

As has been stated, 'using namespace' isn't really good practice for anything general and is especially bad in header files since it cascades and causes namespace pollution. The only thing I ever use 'using namespace' for is inside the CPP files and for my own namespaces; any third party libraries like OGRE and the STL I always explicitly qualify regardless of whether they are in a header or in a source file.
0 x
Insimnax Framework - A game framework for OGRE

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Re: Rename Ogre::map before official 1.7 release?

Post by sinbad » Sun Feb 21, 2010 4:59 pm

What the others said. We won't be changing this.

"using namespace" should always be used with care, but in particular, "using namespace std" is extremely bad form in all but the tightest scopes, best to get it out of your code now. The std namespace includes lots of common words which are guaranteed to clash with something eventually.
0 x

User avatar
Calder
Greenskin
Posts: 124
Joined: Mon Mar 02, 2009 11:04 pm

Re: Rename Ogre::map before official 1.7 release?

Post by Calder » Mon Feb 22, 2010 2:23 am

Ok, thanks for the replies! I'll fix my code if this is such bad practice.
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Rename Ogre::map before official 1.7 release?

Post by jacmoe » Mon Feb 22, 2010 2:41 am

If you want, use this:

Code: Select all

using namespace_name::thing;
Like for std::string, etc.
It's much better.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

Post Reply