Re: [boost] [Review] of binary_int utility starts

Markus Sch?pflin <markus.schoepflin@comsoft.de> wrote:
Compiles and works now without any warnings or errors.
Great. And thanks for trying it.
For the next test, I changed struct test_values (in binary_int_test.cpp) to the following:
struct test_values { uint64_t hex_value; uint64_t bin_value; };
This additionally needs #include <boost/cstdint.hpp>.
When compiling and running this (on both 32 bit and 64 bit systems), I got the following error:
At test_array index 40 8a6c4e20 != ffffffff8a6c4e20 assertion "test_array[i].hex_value == test_array[i].bin_value" failed: file "../binary_int_test.cpp", line 118
Thanks for trying this. I've seen errors like this that were removed by changing all of the literals in the file to unsigned by appending a 'u'. I suspect that there's a problem with the size of the literals on the 64-bit compilers. Does one declare a 64-bit literal by appending a double L ('LL')? If so, then I'll give that a try. Thanks. Scott Schurr

Scott Schurr wrote:
I suspect that there's a problem with the size of the literals on the 64-bit compilers. Does one declare a 64-bit literal by appending a double L ('LL')? If so, then I'll give that a try.
This will depend on the compiler. I am not sure what GCC does, but for MS (and compatible compilers - Borland, CodeWarrior, Intel and others) you do: __int64 biglit = 2i64; unsigned __int64 biglit2 = 2ui64; If GCC has the ll and ull prefixes, you could create a macro for defining signed/unsigned 64-bit literals either where uint64_t is defined or in Boost.Config. e.g.: uint64_t biglit = MAKE_UINT64_T( 2 ); - Reece
participants (2)
-
Reece Dunn
-
Scott Schurr