← Back to context

Comment by fithisux

18 hours ago

Winapi has exploded the last years in terms of functionality, still it was never sanitized to follow any C standard in terms of types.

To be fair, the C standard for types is pretty dreadful. How big is an int? A long? Want an integer type that matches the size of a pointer? <stdint.h> did fix a lot of the issues, but people targeting an early C version don't have this header available.

Windows type names have stayed mostly stable since Win32, but some of them are still misleading. DWORD, UINT and ULONG are all 32-bit unsigned integer types. But in C#, "ulong" is a 64-bit type despite having the same name, this leads to making mistakes when transcribing Win32 type names into C# code.

Windows came up with its type names before <stdint.h> existed, so you won't see any uint32_t in there, just DWORD.

It's not (reasonably) possible to do so though, because it would break so, so much legacy code. The only thing you can do is to add new functionality (e.g. the difference between A and W APIs - A is ASCII, W is UTF-16) or to shoehorn crap onto existing interfaces (again, A APIs to which you pass UTF-8 and pray for the best), but you cannot delete any publicly exposed API or modify existing types.