When using the headers from box2d, I get two warnings.
One is about the typecasting in the inlined b2Math.h :: b2InvSqrt. The other is for the NOT_USED macro in b2WorldCallbacks.h.
I tend to dislike having warnings in my code. Makes me squirmish or something. For the b2InvSqrt, I hacked together an alternative:
Also, a question about the NOT_USED() macro. I commented that line (#54 in b2WorldCallbacks.h) out, since g++ said something about it having no effect. Is that semantically right?
I am compiling on ubuntu using gcc from Box2D v1.4.0, though I checked the 1.4.3 source, and these things weren't changed from the 1.4.0 source. Just something to think about (?)
One is about the typecasting in the inlined b2Math.h :: b2InvSqrt. The other is for the NOT_USED macro in b2WorldCallbacks.h.
I tend to dislike having warnings in my code. Makes me squirmish or something. For the b2InvSqrt, I hacked together an alternative:
Code:
inline float32 b2InvSqrt(float32 x)
{
union {
float32 f;
int32 i;
} union32;
float32 xhalf = 0.5f * x;
#if 1
union32.f = xhalf;
// what the hell does this do!?!?
union32.i = 0x5f3759df - (union32.i >> 1);
x = union32.f;
#else // compiler complains about this
int32 i = *(int32*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float32*)&i;
#endif
x = x * (1.5f - xhalf * x * x);
return x;
}
{
union {
float32 f;
int32 i;
} union32;
float32 xhalf = 0.5f * x;
#if 1
union32.f = xhalf;
// what the hell does this do!?!?
union32.i = 0x5f3759df - (union32.i >> 1);
x = union32.f;
#else // compiler complains about this
int32 i = *(int32*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float32*)&i;
#endif
x = x * (1.5f - xhalf * x * x);
return x;
}
Also, a question about the NOT_USED() macro. I commented that line (#54 in b2WorldCallbacks.h) out, since g++ said something about it having no effect. Is that semantically right?
I am compiling on ubuntu using gcc from Box2D v1.4.0, though I checked the 1.4.3 source, and these things weren't changed from the 1.4.0 source. Just something to think about (?)