...
The compliant solution disables the nonconforming declaration of strerror_r()
by explicitly requesting POSIX conformance before including the <string.h>
header that declares the function and handles the function's failure by copying the "Unknown error"
string into the buffer. An alternate solution is to use the strerror_s()
function defined by Annex K.
Note that the function assigns the result of the call to strerror_r()
to a variable of type int
. This assignment is a defense-in-depth strategy guarding against inadvertently invoking strerror_r()
that returns char*
: a conforming compiler is required to issue a diagnostic for the ill-formed conversion from char*
to int
.
...