std::hash_map missing in VC8?

Problems building or running the engine, queries about how to use features etc.
Post Reply
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

std::hash_map missing in VC8?

Post by Lurb »

Hi I'm making an Ogre/CEGUI based model viewer/importer/exporter for a game and I wanted to use the CEGUI based file dialog instead of popping up the usual windows dialog.

The thing is that I'm using VC++ 2005 Express, and when trying to compile the CEGUI File Dialog code it complained about std::hash_map which seems missing from whatever STL implementation I'm using there.

What would be the best way around this, use STLPort? could that break something with Ogre or the STL based lib I'm using to read and parse the files?
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 6
Contact:

Post by haffax »

Ogre and cegui both compile fine here with vc2005 express. So I know it works.
Please post *exact* steps of what you did (including, but not limited to, versions you used) and the *exact* error messages.
team-pantheon programmer
creators of Rastullahs Lockenpracht
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

Post by Lurb »

Ok, I installed VC++ 2005 Express, Installed MS Platform SDK, followed the 5 post installation steps linked in some thread here, Installed Ogre SDK 1.0.6 for VC8 and I'm happily using Ogre&CEGUI.

I got the code for the CEGUI File Dialog from the Ogre Wiki:
http://www.ogre3d.org/wiki/index.php/CE ... FileDialog

When compiling I get:

CEGUIHashMapTemplates.h(26) : error C2061: syntax error : identifier 'hash_map'
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 6
Contact:

Post by haffax »

Ok, I wasn't aware you were trying to compile some wiki posted extension.
I don't know about the error itself here (no compiler available right now), but I am sure, STLPort won't help you. The compiler doesn't complain about missing the hash_map header, so we can savely assume, this template is available (Else Ogre wouldn't work with VC2005 anyway). So the problem lies elsewhere, but I cannot deduct it from the error message. :(
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

I have not tried to build CEGUI on VC8; does anyone have problems with it?

ISO C++ strict will require addition of "typename" in places that used to work just fine. It possibly is that; if you have CEGUI source, try fixing the offending header and see if it works.
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

Post by Lurb »

Yeah, it's so weird it prompted me to ask, normally I tend to google my way out of everything but this time that's not working.

I now have checked and "hash_map" is in there in the Include subdir of VC8, and it contains a typedef for hash_map.

I'm almost suspecting some cut/paste issues with weird characters slipping in the code, will look at the file with an hex editor...
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Yep, after looking at the code, line 26 in the offending file needs to read

Code: Select all

typename hash_map<Z, T>::iterator hashMapIterator;
in VC8 and above and GCC3.4 and above. It's an ISO C++ strict thing.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

It looks like this should be submitted in the Cegui patch tracker. :wink:
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

Post by Lurb »

Line 26 is actually:

Code: Select all

T getEntryFromHashMap (Z id, hash_map<Z, T>* hashMap)
(This isn't really related to cegui, seems more a general VC8 thing, that's why I initially posted it to the "Back to basics" section.)
Last edited by Lurb on Sun Dec 11, 2005 1:26 am, edited 1 time in total.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

jacmoe wrote:It looks like this should be submitted in the Cegui patch tracker. :wink:
The offending code is in the CEGUI example in the Wiki, though, not in CEGUI (which haffax said compiled fine for him)
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 6
Contact:

Post by haffax »

Yes, Lurb. And this looks correct to me. Though my C++ knowledge is limited in where templates are involved.
It might be worth to go to the Ogre3D channel on IRC and ask Megz about it.
He knows his Kung-Fu. And he will happily delve into any C++ problem. ;)
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

xavier wrote:The offending code is in the CEGUI example in the Wiki, though, not in CEGUI (which haffax said compiled fine for him)
:oops: Indeed it is.
Well, this makes it easier to fix. :wink:
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

Post by Lurb »

Finally Google had it.... someone moved hash_map to namespace stdext.

I have added a warning notice for VC8 users in the Wiki page of the code.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Normally, this is fixed by OgrePrerequisites.h:

Code: Select all

    #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310
    #   define HashMap ::__gnu_cxx::hash_map
    #else
    #   if OGRE_COMPILER == OGRE_COMPILER_MSVC
    #       if OGRE_COMP_VER > 1300 && !defined(_STLP_MSVC)
    #           define HashMap ::stdext::hash_map
    #       else
    #           define HashMap ::std::hash_map
    #       endif
    #   else
    #       define HashMap ::std::hash_map
    #   endif
    #endif
But then you'll have to change the wiki code to use the HashMap define instead of using hash_map directly.
Lurb
Gnoblar
Posts: 9
Joined: Tue Mar 04, 2003 9:17 am

Post by Lurb »

I'll link back to this thread from the Wiki page, to give a choice between the Ogre solution or the "using namespace" quick lazy fix.
.overlord.
Halfling
Posts: 52
Joined: Wed Jun 06, 2007 5:01 pm

Post by .overlord. »

Lurb wrote:I'll link back to this thread from the Wiki page, to give a choice between the Ogre solution or the "using namespace" quick lazy fix.
really .h files shouldn't use the using declaration at all. it
causes namespace pollution
Post Reply