#include <string.h>
char *strerror(int errnum);
int strerror(int errnum, char *strerrbuf, size_t buflen);
The strerror() function maps errnum,
a possible value of errno, to an error message string.
Note that subsequent calls to strerror() may overwrite the
buffer addressed by the returned pointer.
Like strerror(), the strerror_r()
function maps errnum to an error message string. Unlike
strerror(), it returns that error message string in
the buffer pointed to by strerrbuf with length
bufflen.
- errnum
-
Is the value of errno to interpret.
- strerrbuf
-
Points to a buffer where strerror_r() returns the error
message string.
- buflen
-
Specifies the length of the strerrbuf buffer.
The strerror() function returns a pointer to a
null-terminated string that describes the error condition associated
with the global variable errno having a value of
errnum. If errnum is negative,
strerror() interprets its absolute value as a
Win32 error code; MKS Toolkit UNIX APIs functions set errno to a negative
value to indicate a Win32-specific error.
If errnum cannot be interpreted, strerror()
returns a pointer to a string indicating that the error is unknown and sets
errno to EINVAL.
On success, the strerror_r() function returns 0. Otherwise,
it returns an appropriate error number. This error number is usually either
EINVAL indicating an unknown error or ERANGE
indicating that the buffer specified by strerrbuf and
buflen was not large enough to hold the error message string.
ANSI/ISO 9899-1990, with exceptions.
MT-Safe.
Because MKS Toolkit UNIX APIs functions set errno to a negative value if a
Win32 error condition cannot be mapped to a standard UNIX errno
value, use strerror() (or strerror_r()
rather than directly accessing the global array sys_errlist.
The API-Specific Porting Issues
section of the MKS Toolkit UNIX to Windows Porting Guide
includes a detailed discussion of strerror(). In addition,
the api_intro reference page includes a table of mappings
from Win32 error codes to UNIX errno values.
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
api_intro
- Functions:
- perror()
- Miscellaneous:
- errno, sys_errlist
MKS Toolkit 9.2 Documentation Build 16.