#Find possible win32 error codes like in stdlib?
1 messages · Page 1 of 1 (latest)
in release modes undefined can be any value
including 0xaa
its value is undefined
eg in practice its whatever value was in that memory location before
there is no way to detect use of undefined in release modes by definition, dont try
I thought undefined / uninitialized memory meant that it had "nothing" or pointed to a non existing location or smth but 2 seconds of Wikipedia says otherwise 
Is there a better way to do what I was trying to do than passing undefined then?
Trying to see what behavior / errors I can get from a C function with invalid arguments
It's Win32 API
Their docs basically say something like: "it has too many changing variables depending on the machine, we can't document all the errors this thing returns"
then iterate over every possible input or something idk
what's the function?
Well nothing specific, it's a whole bunch of stuff I use, but here's an example: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos
The error codes returned by a function are not part of the Windows API specification and can vary by operating system or device driver. For this reason, we cannot provide the complete list of error codes that can be returned by each function. There are also many functions whose documentation does not include even a partial list of error codes that can be returned.
I looked at stdlib before and this's all I found:
https://github.com/ziglang/zig/blob/master/lib%2Fstd%2Fos.zig#L5670-L5673
/// Whether or not error.Unexpected will print its value and a stack trace.
/// if this happens the fix is to add the error code to the corresponding
/// switch expression, possibly introduce a new error in the error set, and
/// send a patch to Zig.
Find possible win32 error codes like in stdlib?
the list of error codes starts at https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
That I do know, it has an enum in std.os.windows.Win32Error as well
It's more about "which ones does X function return?"
pretty sure that'd be an implementation detail on microsoft's side
yeah seems so, yet stdlib seems to have a grip on them somehow
I would assume a good chunk of this might come from looking at wine source code, but wine doesn't port all functions
from the git history, looks like they were added one by one in reaction to the errors occurring in the wild
guess so ¯_(ツ)_/¯
I'll prolly do the same then
Passing undefined seemed to give at least some info tho, should I just keep doing that to at least get what I can or could it be bad for some reason?
it's virtually the equivalent of passing a random number from a very bad rng
if you need to know all the possible unexpected errors to display relevant messages to the user, you'd be better of using FormatMessage rather than rolling your own
otherwise "did it work?" "yes/no(unknown)/no(handled)" is likely enough at runtime, and when debugging the unknown error codes can always be looked up