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
x 3

Rename Ogre::map before official 1.7 release?

Post by Calder »

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...
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 »

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.
User avatar
MrD
Goblin
Posts: 292
Joined: Wed Oct 21, 2009 3:16 pm
Location: England
x 1

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

Post by MrD »

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.
Insimnax Framework - A game framework for OGRE
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

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

Post by sinbad »

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.
User avatar
Calder
Greenskin
Posts: 124
Joined: Mon Mar 02, 2009 11:04 pm
x 3

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

Post by Calder »

Ok, thanks for the replies! I'll fix my code if this is such bad practice.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

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

Post by jacmoe »

If you want, use this:

Code: Select all

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