error C2872: 's32' : ambiguous symbol

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
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

error C2872: 's32' : ambiguous symbol

Post by utimagus »

So i'm trying to be one of the hundreds of people who are trying to make the next hot game. I managed to get a login screen to pop up just fine, but when I added in RakNet and compile (not using any code from RakNet except for the headers) I get the following 10 errors.

------ Build started: Project: Tempest-ToW, Configuration: Debug Win32 ------
Compiling...
Tempest-ToW.cpp
d:\tactics multiplayer\tempest-tow\tempest-tow\states.h(30) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\states.h(38) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\gui.h(20) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\gui.h(21) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\gui.h(22) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\gui.h(23) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\tempest-tow.cpp(50) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\tempest-tow.cpp(59) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\tempest-tow.cpp(70) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
d:\tactics multiplayer\tempest-tow\tempest-tow\tempest-tow.cpp(76) : error C2872: 's32' : ambiguous symbol
could be 'd:\tactics multiplayer\3d engines\irrlicht-1.1\irrlicht-1.1\include\irrtypes.h(42) : int irr::s32'
or 'd:\tactics multiplayer\raknet\include\types.h(299) : cat::s32'
Build log was saved at "file://d:\Tactics Multiplayer\Tempest-ToW\Tempest-ToW\Debug\BuildLog.htm"
Tempest-ToW - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Anyone have an idea on how to resolve this?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It is a namespace collision. Irrlicht and RakNet both define the type s32 and the compiler cannot tell which one to use... Here is what the compiler sees...

Code: Select all

// from irrlicht headers
namespace irr
{
  typedef s32 int; 
}

// from raknet headers
namespace cat
{
  typedef s32 int;
}

// your code
using namespace irr;
using namespace cat;

s32 s = 0;
The compiler could use irr::s32 or cat::s32 for the type s. Even though the types are the same under the covers, the compiler must treat them as being different.

You have two choices. You can explicitly tell the compiler which one you want... You can do this by typing irr::s32 where you want the Irrlicht type, and cat::s32 where you want the RakNet type. The other choice is to avoid the name collision in the first place. You can do this by removing the using clause for one of the namespaces. Either way, you'll need to make some code changes.

Travis
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

ahhhh, makes sense. Shall make the needed changes.
Post Reply