I have seen Symbolic errno to String - Stack Overflow, so even if that question is bash
related, I can already tell that this isn't trivial; but just to confirm:
Is there a C API function, which like strerror()
will accept the numeric errno
as argument - but which will print the mnemonic (e.g. EINVAL
) instead of the error description string (e.g. "Invalid argument")?
As an example, I'd like
printf("Number: %d (%s): '%s'\n", 22, strerror_mnemonic(22), strerror(22) );
... to print:
Number: 22 (EINVAL): 'Invalid argument'
... where strerror_mnemonic
is pseudocode for the C function I'm looking for.