Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-09-17 10:33:36


Matthias Troyer wrote:

> This seems to be fine if all you want is compatibility at the level
> of the least common denominator. By checking if the value of an
> integer fits into 32 bits you make this library archive useless for
> people who might need compatibility between 64 bit platforms. What do
> you think about the following idea: the portable binary archive
> implements serialization for the fixed length integers (int32_t,
> int64_t, ...) and it is the user's responsibility to only use the 32
> bit integers if they want portability to all 32 bit platforms. Also
> watch out that on some platforms even short and int are 64 bit.
>
Note that the version of portable_binary that is included with the demo
addresses this issue - even though its no explicitly stated. It stores the
integers in a compiler independent format - length - bytes using save_binary
and restores them using load_binary. If it turns out that the saved
integer_type from platform A is too large to fit into the loaded
integer_type on platorm B it throws a run-time exception. Now if one uses
say int32_t then he is guarenteed that on both platforms the integer will
fit in 32 bit so the exception can never be thrown. (Well almost never, if
someone stored a 64 bit integer in int32_t on platform A it would be a
problem - but that's really a programming error of the user - and in any
case one would get an exception)

So in my view, handling int32_t and its bretheren shouldn't be any sort of
issue.

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk