#4977·windows-rs

RDL introduced a lot of type inconsistencies

Author: sylveonCreated Sep 20, 2026Updated Sep 23, 2026
Labelsquestion

Summary

The switch to RDL from win32-metadata is a... painful one for downstream consumers of windows-rs, with a lot of changes. One of them is the new creation of inconsistencies between functions and their associated constants. For example, to list the ones that came up so far when migrating my code:

  • SetConsoleCtrlHandler's callback takes a parameter of type u32, but the associated constants like CTRL_C_EVENT are i32
  • GetLastError/SetLastError take and return an u32 while all error constants are i32
  • SetWinEventHook's dwFlags parameter is of type u32, but the named constants are of type i32

Having to constantly do these as casts is annoying, pointless and makes it harder to concentrate on actual logic. For example, the samples and windows-rs crates have code like WIN32_ERROR(ERROR_INVALID_DATA as u32), which really should just be WIN32_ERROR(ERROR_INVALID_DATA).

Crate manifest

toml

Crate code

rust