Closed BrainStone closed 6 years ago
My guess is there's no version of mpz_class that takes an LLU.
Well my issue is that compiles under VisualStudio and it's being advertised to support 64 bit integers. (Even on 32 bit architecture. But I tried compiling it for both)
Probably should have clarified that in the issue. Will do that tomorrow.
long is 64 bits on linux. It should work if you use UL instead of LLU.
I’ll try it with just the U. As the length should be detected automatically. Though I think I already tried that 🤔
I’ll give it a try later.
I don't think the same code will work under both compilers. Usually people work around this by defining a macro for constant literals, that expands one way on Windows and another way on Linux.
Well one thing is for sure. GCC makes a difference between long int
and long long int
. Just according to the compiler error itself: __gmp_expr(long long unsigned int)
Anyways why isn’t the lib using unambiguous ints like uint32_t
or int64_t
. At least for the C++ part?
They are standardized for at least C++ and even C if I’m not mistaken.
This would mean rewriting all code that depends on GMP, which is tens of millions of lines of code.
It's also not as simple as it might seem to get something portable. Not all compilers distinguish long int and long long int (one is an alias for the other), so if you define the functions for both, you end up with a duplicate definition (this is how MPIR used to be, but we had to revert it after this was discovered).
MPIR makes no attempt to turn C/C++ into a portable language. You still have to write portable code when using it.
I see. You can't do it right xD
Some people need support for long long int
and others don't.
Anyways, I think just using mpz_class( 9681666858668565181U )
should work, as that makes it unsigend (the value is too large for int64_t
).
I didn't know that GCC makes a difference between long int
and long long int
even though they both are 64-bit ints.
I think that concludes this issue. Thank you for your swift support and moreover this wonderful project. Without it I'd still be banging my head against the wall trying to get GMP running on windows ;)
When trying to compile the following snippet:
with GCC (and Clang, iirc) it results in this compilation error: