Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fixed-width int types for portability #66

Open
tromer opened this issue Jan 26, 2017 · 5 comments
Open

Use fixed-width int types for portability #66

tromer opened this issue Jan 26, 2017 · 5 comments

Comments

@tromer
Copy link
Member

tromer commented Jan 26, 2017

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.)

@daira
Copy link

daira commented Jan 27, 2017

Are we sure it is long long (rather than long) that is 32 bits? C99 requires long long to be at least 64 bits.

@radix42
Copy link

radix42 commented Jan 27, 2017 via email

@jmprcx
Copy link

jmprcx commented Jan 27, 2017

To add onto what @radix42 mentioned.. Even size_t is potentially problematic (32 bits on Win64 vs 64 bits on Linux/Unix).

@tromer
Copy link
Member Author

tromer commented Jan 31, 2017

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.

@daira
Copy link

daira commented Feb 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants