While developing WinSafe, it’s very common to convert the Windows integral data types to their Rust equivalent. Care must be taken, however, when it comes to pointer size, which varies according to the architecture. Since WinSafe is aimed to both 32 and 64-bit Windows, I must pay attention.
For reference, below is the table I’m using to figure out the sizes:
| Signed C | Signed Rust | Unsigned C | Unsigned Rust | 32-bit | 64-bit |
|---|---|---|---|---|---|
CHAR |
i8 |
UCHARBYTEBOOLEAN
|
u8 |
8 bit (1 byte) | |
SHORT |
i16 |
USHORTWCHARWORD
|
u16 |
16 bit (2 byte) | |
BOOLINTLONG |
i32 |
UINTULONGDWORD
|
u32 |
32 bit (4 byte) | |
INT_PTRLONG_PTRLPARAM |
isize |
UINT_PTRULONG_PTRWPARAMSIZE_T
|
usize |
32 bit (4 byte) | 64 bit (8 byte) |
LARGE_INTEGERLONG64LONGLONG |
i64 |
ULARGE_INTEGERULONG64ULONGLONGDWORD64DWORDLONGQWORD
|
u64 |
64 bit (8 byte) | |
The table above is an extension of this one.
1 comment:
This conversion chart will be very helpful for development.
Post a Comment