Chewi
11-04-2008 14:53:47
Hi. I've created a Gentoo ebuild for OgreODE CVS, which I will submit to Gentoo shortly. However, I hit some compiler errors and I want to try and get this patch committed upstream first. They occur when using GCC 4.2. With 3.4, they were merely reported as warnings. Judging by the threads I've seen, this didn't affect 4.1. Here are the first errors.
I was able to fix that and the subsequent errors with this patch.
To be honest, I'm not sure why these were casted to unsigned int before when an unsigned long is expected. The type being cast is a pointer and this would be 32-bit (int sized) on a 32-bit x86 machine so maybe that was the thinking behind it.
OgreOdeBody.cpp: In member function 'OgreOde::Joint* OgreOde::Body::getJoint(int)':
OgreOdeBody.cpp:523: error: cast from 'dxJoint*' to 'unsigned int' loses precision
OgreOdeBody.cpp: In destructor 'virtual OgreOde::Body::~Body()':
OgreOdeBody.cpp:720: error: cast from 'dxBody*' to 'unsigned int' loses precision
I was able to fix that and the subsequent errors with this patch.
diff -Naur src.old/OgreOdeBody.cpp src/OgreOdeBody.cpp
--- src.old/OgreOdeBody.cpp 2008-04-10 15:36:12.287711000 +0100
+++ src/OgreOdeBody.cpp 2008-04-10 15:37:36.761626690 +0100
@@ -520,7 +520,7 @@
//-----------------------------------------------------------------------
Joint* Body::getJoint(int index)
{
- return (Joint*)_world->getJointList().findItem((unsigned int)dBodyGetJoint(_body,index));
+ return (Joint*)_world->getJointList().findItem((unsigned long)dBodyGetJoint(_body,index));
}
//-----------------------------------------------------------------------
size_t Body::getGeometryCount()
@@ -717,7 +717,7 @@
destroyDebugNode();
delete _mass;
- _world->getBodyList().unregisterItem((unsigned int)_body);
+ _world->getBodyList().unregisterItem((unsigned long)_body);
dBodyDestroy(_body);
}
diff -Naur src.old/OgreOdeGeometry.cpp src/OgreOdeGeometry.cpp
--- src.old/OgreOdeGeometry.cpp 2008-04-10 15:36:12.298626000 +0100
+++ src/OgreOdeGeometry.cpp 2008-04-10 15:37:36.762876728 +0100
@@ -211,7 +211,7 @@
{
_debug_contacts = new DebugContact*[_max_contacts];
for (unsigned int i = 0; i < _max_contacts; i++)
- _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((int)_geom) +
+ _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((long)_geom) +
"_Contact_" +
Ogre::StringConverter::toString(i),
_world);
@@ -273,7 +273,7 @@
//------------------------------------------------------------------------------------------------
Space* Geometry::getSpace()
{
- return (Space*)_world->getSpaceList().findItem((unsigned int)dGeomGetSpace(_geom));
+ return (Space*)_world->getSpaceList().findItem((unsigned long)dGeomGetSpace(_geom));
}
@@ -425,7 +425,7 @@
}
_debug_contacts = new DebugContact*[max_contacts];
for (unsigned int i = 0; i < max_contacts; i++)
- _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((int)_geom) + + "_Contact_" + Ogre::StringConverter::toString(i),
+ _debug_contacts[i] = new DebugContact(Ogre::StringConverter::toString((long)_geom) + + "_Contact_" + Ogre::StringConverter::toString(i),
_world);
}
_max_contacts = max_contacts;
diff -Naur src.old/OgreOdeJoint.cpp src/OgreOdeJoint.cpp
--- src.old/OgreOdeJoint.cpp 2008-04-10 15:36:12.303420000 +0100
+++ src/OgreOdeJoint.cpp 2008-04-10 15:37:36.762876728 +0100
@@ -35,7 +35,7 @@
JointGroup::~JointGroup()
{
- _world->getJointGroupList().unregisterItem((unsigned int)_joint_group);
+ _world->getJointGroupList().unregisterItem((unsigned long)_joint_group);
dJointGroupDestroy(_joint_group);
}
diff -Naur src.old/OgreOdeSpace.cpp src/OgreOdeSpace.cpp
--- src.old/OgreOdeSpace.cpp 2008-04-10 15:36:12.312932000 +0100
+++ src/OgreOdeSpace.cpp 2008-04-10 15:37:36.763876673 +0100
@@ -62,7 +62,7 @@
//------------------------------------------------------------------------------------------------
Geometry* Space::getGeometry(int index)
{
- return (Geometry*) _world->getGeometryList().findItem((unsigned int)dSpaceGetGeom(_space,index));
+ return (Geometry*) _world->getGeometryList().findItem((unsigned long)dSpaceGetGeom(_space,index));
}
//------------------------------------------------------------------------------------------------
void Space::registerSpace()
To be honest, I'm not sure why these were casted to unsigned int before when an unsigned long is expected. The type being cast is a pointer and this would be 32-bit (int sized) on a 32-bit x86 machine so maybe that was the thinking behind it.