
I'm having a load of trouble getting Boost.Integer to play nice with the Borland/Codegear compilers, for example given: void print_val(long long l) { std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFF00000000LL) >> 32); std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFFLL)) << std::endl; } And then: static const long long MaxValue = SCHAR_MAX; static const long long sll = _LLONG_MAX; const long long cll = _LLONG_MAX; long long ll = _LLONG_MAX; BOOST_TEST(MaxValue <= ::boost::integer_traits<boost::long_long_type>::const_max); // fails BOOST_TEST(MaxValue <= _LLONG_MAX); // passes BOOST_TEST(MaxValue <= sll); //fails BOOST_TEST(MaxValue <= cll); // fails BOOST_TEST(MaxValue <= ll); // passes print_val(_LLONG_MAX); // OK prints 7fffffffffffffff print_val(ll); // OK prints 7fffffffffffffff print_val(sll); // Oh no, prints ffffffffffffffff print_val(cll); // Oh no, prints ffffffffffffffff So as soon as a long long is declared const (whether static or not) it seems to be incapable of actually holding a sensible value!! Anyone got any ideas what's going on or any workarounds? Thanks, John. PS I'm still using Borland-5.8.2, but judging by the test matrix results the latest versions have similar issues.

John Maddock wrote:
I'm having a load of trouble getting Boost.Integer to play nice with the Borland/Codegear compilers, for example given:
void print_val(long long l) { std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFF00000000LL) >> 32);
I've no idea whether this matters or not, but the constant 0xFFFFFFFF00000000 does not fit in long long. I think that you need an ull suffix for it... or leave the suffix out. You could also try static_cast<unsigned> instead of int.

I'm having a load of trouble getting Boost.Integer to play nice with the Borland/Codegear compilers, for example given:
void print_val(long long l) { std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFF00000000LL) >> 32);
I've no idea whether this matters or not, but the constant 0xFFFFFFFF00000000 does not fit in long long. I think that you need an ull suffix for it... or leave the suffix out. You could also try static_cast<unsigned> instead of int.
Good point, doesn't make any difference to program output though... that code was just there so I could actually print out a long long. John.

"John Maddock" <john@johnmaddock.co.uk> writes:
I'm having a load of trouble getting Boost.Integer to play nice with the Borland/Codegear compilers, for example given:
So as soon as a long long is declared const (whether static or not) it seems to be incapable of actually holding a sensible value!!
I've found that before, and failed to find a workaround. You can't use long long values sensibly as non-type template parameters either, especially if you want to use their values for template specializations. I gave up trying to use long long with Codegear's compiler. Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

I'm having a load of trouble getting Boost.Integer to play nice with the Borland/Codegear compilers, for example given:
So as soon as a long long is declared const (whether static or not) it seems to be incapable of actually holding a sensible value!!
I've found that before, and failed to find a workaround. You can't use long long values sensibly as non-type template parameters either, especially if you want to use their values for template specializations.
I gave up trying to use long long with Codegear's compiler.
OK, sounds like a Boost.Config change is necessary then to flag that up, I'll look into that. Thanks, John.
participants (3)
-
Anthony Williams
-
John Maddock
-
Peter Dimov