Add helper to log Windows system errors

It will help to log errors returned by GetLastError() or
WSAGetLastError():
 - <https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror>
 - <https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsagetlasterror>
 - <https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes#system-error-codes>

Always log the errors in English to be able to read them in bug reports.
This commit is contained in:
Romain Vimont
2022-01-28 09:05:36 +01:00
parent 5508c635cb
commit 80bec70852
3 changed files with 31 additions and 8 deletions

View File

@@ -26,4 +26,10 @@ sc_set_log_level(enum sc_log_level level);
enum sc_log_level
sc_get_log_level(void);
#ifdef _WIN32
// Log system error (typically returned by GetLastError() or similar)
bool
sc_log_windows_error(const char *prefix, int error);
#endif
#endif