Use fixed-width int types for portability
tromer opened this issue · comments
Libsnark currently uses long
long and unsigned long
long in many places. On native Windows build, these are 32-bit types (even on 64-bit Windows), which breaks compatibility (#26) and in some cases correctness (e.g., #13).
Convert all of these to C++11 fixed-width integer types: int64_t
and uint64_t
.
Except where they should be size_t
instead (e.g., zcash/zcash#1240).
(Ongoing work by @radix42 and @joshuayabut.)
Are we sure it is long long
(rather than long
) that is 32 bits? C99 requires long long
to be at least 64 bits.
To add onto what @radix42 mentioned.. Even size_t is potentially problematic (32 bits on Win64 vs 64 bits on Linux/Unix).
The difference in the size of size_t
shouldn't matter, as long as it's used correctly (i.e., just for sizes, array indices, etc.) rather than data (e.g., bigint limbs).
Platform dependencies may arise when it needs to be cast into other integer types (or in overloading); but these should be caught at compile/link time, and in this case it makes sense to have an explicit cast.
See discussion and example in zcash/zcash#1240.