The nob__walk_dir_opt_impl() function calls nob_dir_entry_close() in the defer, to close the current entry.
It also does this when the entry is not a directory, and therefore the directory handle is NULL.
On Linux, there is a check not to close NULL handles in the nob_dir_entry_close() function, as they are returned on erroneous open.
On Windows, on the other hand, the error handle is INVALID_HANDLE_VALUE, which is not checked anyway.
This results in calls to FindClose with a NULL handle. The result of the close function is not checked, so it continues normally in C.
But FindClose throws an exception, ending the program when used from C++, and more annoyingly triggers the debugger.
The nob__walk_dir_opt_impl() function calls nob_dir_entry_close() in the defer, to close the current entry.
It also does this when the entry is not a directory, and therefore the directory handle is NULL.
On Linux, there is a check not to close NULL handles in the nob_dir_entry_close() function, as they are returned on erroneous open.
On Windows, on the other hand, the error handle is INVALID_HANDLE_VALUE, which is not checked anyway.
This results in calls to FindClose with a NULL handle. The result of the close function is not checked, so it continues normally in C.
But FindClose throws an exception, ending the program when used from C++, and more annoyingly triggers the debugger.