What happens if the types don't match?

There is no guarantee that when you build a library on a 32-bit platform, an int will have the same size_t as an int on a 64-bit platform. They usually will, but there is no guarantee. A simple example is this:

sizeof(char) == 1 
sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long) 

Therefore, a short can be the same size as a long! More usually, though, int will be the platform word size (32 bits on a 32-bit processor, 64 bits on a 64-bit processor).

Values for floats are stricter and comply with the IEEE 754 standards.

There is not normally an issue if the Rust application is built on a 64-bit platform and the library is 32 bits. If it is the other way around, however,there is a chance that an overflow may occur. It is unlikely, but worth keeping in mind.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset