On 1/03/2018 11:10, Niall Douglas wrote:
On all systems, there is a typedef `system_code` which is to the erased status code sufficiently large that you are guaranteed that all possible system error coding schemes can be safely erased into it. For POSIX, this is `status_code
`, as `int` can hold all possible error codings. For Windows, this is `status_code >`, as `intptr_t` can hold any of a `DWORD`, a `LONG` and a `HRESULT`.
DWORD (aka uint32_t) can hold any of DWORD, LONG, and HRESULT. Or use LONG (aka int32_t) if you want to retain signedness of LONGs, though I don't think any Win32 APIs require this. In any case intptr_t is either larger than needed to preserve the value bits (in 64-bit applications) or smaller than needed to preserve the value and sign (in 32-bit applications), so this seems like an inappropriate choice. (HRESULT is not a pointer type, despite most other H* types being derived from HANDLE. Yay for consistency.)