strerror_r ¶POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/strerror_r.html
LSB specification:
Gnulib module: strerror_r-posix
Portability problems fixed by Gnulib:
_LINUX_SOURCE_COMPAT
have an incompatible version of this function.
The POSIX compliant code
char *s = (strerror_r (err, buf, buflen) == 0 ? buf : NULL);
is essentially equivalent to this code using the glibc function:
char *s = strerror_r (err, buf, buflen);
strerror buffer on some platforms:
Cygwin 1.7.9.
<string.h> on some platforms:
glibc 2.8.
int instead of size_t on some
platforms:
AIX 5.1.
errno, instead of
returning the error number, on some platforms:
glibc 2.12 with -D_POSIX_C_SOURCE=200112L, AIX 6.1.
errno, on some platforms:
Solaris 10.
<errno.h> on
some platforms:
MSVC 14.
strerror_r(0, buf, len),
although POSIX requires this to succeed, on some platforms:
FreeBSD 8.2.
0 than
strerror on some platforms:
macOS 14.
Portability problems not fixed by Gnulib:
Note: Gnulib has a module xstrerror, with the property that
xstrerror (NULL, errnum) returns the value of strerror_r
as a freshly allocated string.
(Recall that the expression strerror (errnum) is not multithread-safe.)