[ODE] compile error

Bram Stolk bram at sara.nl
Mon Mar 27 03:58:14 MST 2006


c2sode at gmail.com wrote:
> Hi all,
> 
> I have some compile errors in my program like:
> 
>  error C2440: 'initializing' : cannot convert from 'const double *' to
> 'const dReal *'
>         Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>  error C2440: 'return' : cannot convert from 'const dReal *' to 'const
> double *'
>  error C2440: 'return' : cannot convert from 'dMatrix3' to 'const double *'
>         Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> 
> For example the first error comes from:
> const dReal *pos = getGeomPosition (geomID); //
> 
> The second:
> const double* CarPhysics::getGeomRotation(dGeomID geom)
> {
>     const dReal *R    = dGeomGetRotation (geom);
>     if (dGeomGetClass(geom) != dGeomTransformClass)
>         return R;
> }


It looks like you have configured ODE with single precision.
If you do ./configure --with-double-precision then your
code is probably valid.

if dReal is a float, you most certainly cannot cast a
dReal* to a double*

You can create code that works with any ODE config, by copying
and converting the data like this:

  const dReal *APos = dBodyGetPosition(capbody);
  const dReal *ARot = dBodyGetRotation(capbody);
  float apos[3] = {APos[0], APos[1], APos[2]};
  float arot[12] = { ARot[0], ARot[1], ARot[2], ARot[3], ARot[4], ARot[5], ARot[
6], ARot[7], ARot[8], ARot[9], ARot[10], ARot[11] };

Here, you end up with floats in apos and arot, regardless of the
definition for dReal, being either float or double.

  bram



> 
> 
> Aren't these abnormal errors? When this code is compiled on another
> machine, it gives no error. But it gives these compile errors in my
> machine. Do you have any idea, why these errors occur? Is there the
> possibility that ode-0.5 in my machine is  not installed properly? Or is
> there something missing?
> I'm waiting for your help...
> 
> Thanks.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode


More information about the ODE mailing list