[Bouncing replies to flightgear-devel, for obvious reasons]
James Cliburn wrote:
> AIBase.cxx:389: error: cast from 'const FGAIBase*' to 'int'
> loses precision
This is a 64 bitness bug; the AI subsystem wants to cast the pointer
to an integer to use as an "ID" for an object. Obviously this is a
problem when the integer is smaller.
GCC 4.0.x thinks this kind of typecasting bug is such a problem that
it throws an error, and not a warning. You can get away with it by
doing a double cast -- cast the pointer to an integer of the same
size, and then cast the 64 bit integer down to 32 bits:
--- AIBase.cxx 3 Jul 2005 09:39:14 -0000 1.38
+++ AIBase.cxx 4 Aug 2005 14:20:44 -0000
@@ -393,7 +393,7 @@
}
int FGAIBase::_getID() const {
- return (int)(this);
+ return (int)(long)this;
}
This really isn't a good solution, because in principle two pointer
values could have the same bottom bits and the ID wouldn't be unique.
But it seems unlikely to be a problem in practice, so I've left it in
place. A better solution would be to convert the ID system to a type
of the right size (size_t, for example) and/or stop using pointer
values for it.
Andy
_______________________________________________
Flightgear-users mailing list
[email protected]
http://mail.flightgear.org/mailman/listinfo/flightgear-users
2f585eeea02e2c79d7b1d8c4963bae2d