Mathias Fröhlich wrote:
On Donnerstag 11 August 2005 10:20, Erik Hofman wrote:
Andy Ross wrote:
> There is a similar spot in FlightGear where something wants to use a
pointer as an integer "ID". I haven't checked these in as this is not
really a good solution -- the ID needs to be guaranteed-unique.
I just noticed there is even an id_t in sys/types.h on IRIX, is this
common?
I don't think so.
The only type I know that is guaranteed to be capable of storing the whole
pointer is a void*. But void* is menat to be not that pure address number in
the properties, it is meant to store some arbitrary property, which is ok so
far.
But I believe that for our problem, it would be sufficient if we just convert
that address to a string and take this string as an id.
That saied how about something like
stringstream s;
s << this;
and then take
s.str()
as that id?
Greetings
Mathias
Using strings add too much overhead for a general solution, void * could
be better except that those pointers
can not really be compared (if you want to use your id in a map you must
have a < operator that does
not exist here).
But those ID are not pointers, they are just random numbers so 'id =
++static_counter' is sufficient.
Harald.
_______________________________________________
Flightgear-devel mailing list
[email protected]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d