strerror_r() — Get copy of runtime error message

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, Version 3

both

z/OS V1R7

Format

#define _UNIX03_SOURCE
#include <string.h>

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

General description

strerror_r() maps the error number in errnum to an error message string and copies the message string into the buffer pointed to by strerrbuf with length buflen. If the length of the message string is greater than or equal to buflen, strerror_r() copies the first buflen-1 characters of the message string into strerrbuf, terminates strerrbuf with a null character (\0) and returns ERANGE. The error number must be a valid errno value.

This function does not produce a locale-dependent error message string.

Returned value

If successful, strerror_r() returns 0.

If unsuccessful, strerror_r() returns an error number to indicate the error.
  • EINVAL – The value of errnum is not a valid error number.
  • ERANGE – Insufficient storage was supplied via strerrbuf and buflen to contain the generated message string.

Related information