
Michael Glassford wrote:
Ben Hutchings wrote:
Michael Glassford <glassfordm@hotmail.com> wrote:
Ben Hutchings wrote:
The implementation of the boost::xtime_get() function in libs/thread/src/xtime.cpp includes the following code for Windows:
<snip>
The pointer casts are not safe because although the representations of FILETIME and __int64 are compatible, FILETIME is only 32-bit- aligned whereas __int64 must be 64-bit-aligned on IA64 (in some processor modes).
One can instead use union { FILETIME ft; __int64 i64; } and read out i64, though I'm not sure this code should be unconditionally using __int64 anyway. There is a longer explanation at <http://weblogs.asp.net/oldnewthing/archive/2004/08/25/220195.aspx>.
How about this instead:
const boost::uint64_t TIMESPEC_TO_FILETIME_OFFSET = (static_cast<boost::uint64_t>(27111902UL) << 32) + 3577643008UL;
I think this should use the UINT64_C macro instead of messing about with casts.
OK.
I see this is defined in boost/cstdint.hpp, but only if __STDC_CONSTANT_MACROS is #defined. How does this happen? Do I #define it myself, or does it get #defined some other way?
Any help on how to use the Boost UINT64_C macro? Mike