strerror(), strerror_r()

map errno value to error message string 

Function


SYNOPSIS

#include <string.h>

char *strerror(int errnum);

int strerror(int errnum, char *strerrbuf, size_t buflen);


DESCRIPTION

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.


PARAMETERS

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.


RETURN VALUES

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; PTC 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.


CONFORMANCE

ANSI/ISO 9899-1990, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

Because PTC 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 PTC 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.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

api_intro

Functions:
perror()

Miscellaneous:
errno, sys_errlist


PTC MKS Toolkit 9.6 Documentation Build 9.