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 |
UCHAR BYTE BOOLEAN
|
u8 |
8 bit (1 byte) | |
SHORT |
i16 |
USHORT WCHAR WORD
|
u16 |
16 bit (2 byte) | |
BOOL INT LONG |
i32 |
UINT ULONG DWORD
|
u32 |
32 bit (4 byte) | |
INT_PTR LONG_PTR LPARAM |
isize |
UINT_PTR ULONG_PTR WPARAM SIZE_T
|
usize |
32 bit (4 byte) | 64 bit (8 byte) |
LARGE_INTEGER LONG64 LONGLONG |
i64 |
ULARGE_INTEGER ULONG64 ULONGLONG DWORD64 DWORDLONG QWORD
|
u64 |
64 bit (8 byte) |
The table above is an extension of this one.
No comments:
Post a Comment