winapi-rs
winapi-rs copied to clipboard
c_void has incorrect layout in no_std
This will be fixed with #771, but still reporting this just in case. In no_std, c_void has a size of 0 instead of 1.
Does the layout matter?
If you use add() or similar on a pointer to c_void it does nothing, since the size is zero, rather than adding that many bytes.
That makes winapi's own c_void different from C's void as in C adding to the void* also adds that number of bytes to the pointer.
_Bool test(void* p) {
return p + 5 == (char*)p + 5;
}
test: # @test
mov al, 1
ret
Just ran into a bug in my code where I wanted to offset some allocated memory (VirtualAllocEx returns LPVOID which is *mut winapi::ctypes::c_void), where add(offset) was a no-op because winapi's c_void is a ZST.