Add a thread-safe wxSysErrorMsgStr()

Implement wxSysErrorMsg's functionality without using static buffers;
have the caller provide the buffer. When the caller uses the original
API and does not provide a buffer, a static buffer is still used.
wxSysErrorMsgStr() returns a wxString.

Also use strerror_r() instead of strerror() on platforms other than MSW.
This commit is contained in:
Lauri Nurmi
2016-10-25 12:01:03 +03:00
parent 3926538fea
commit 343318d73e
3 changed files with 64 additions and 17 deletions

View File

@@ -1226,6 +1226,23 @@ unsigned long wxSysErrorCode();
@a errCode is 0 (default), the last error code (as returned by
wxSysErrorCode()) is used.
Use this function instead of wxSysErrorMsg(), as the latter one is not
thread-safe.
@see wxSysErrorCode(), wxLogSysError()
@header{wx/log.h}
*/
wxString wxSysErrorMsgStr(unsigned long errCode = 0);
/**
Returns the error message corresponding to the given system error code. If
@a errCode is 0 (default), the last error code (as returned by
wxSysErrorCode()) is used.
Use wxSysErrorMsgStr() instead of this function especially in a
multi-threaded application.
@see wxSysErrorCode(), wxLogSysError()
@header{wx/log.h}