Is there any function in UNIX to the convert errno to its corresponding string for e.g. EIDRM to "EIDRM". Its very annoying to debug to check for errors with these integer errnos.
strerror()
should do it. http://linux.die.net/man/3/strerror
FYI, so that you can find these things more easily, yourself: If you type man errno (or whatever function you're investigating), and look at the very bottom of the man page, you'll see a list of related functions. If you man
each of those (taking a guess about which one(s) to do first based on their names) you'll often find the answer to similar questions.
I'm not sure about such enum
-style names, but for debugging and error reporting purposes you may use perror(3)
or strerror(3)
C functions that return a human-readable representation of the error code. Please refer to the man pages for more details.
Just another solution that solves exactly the problem you have, but in Python instead of C:
>>> import errno
>>> errno.errorcode[errno.EIDRM]
'EIDRM'
If you do indeed want EIDRM and not its error string: no. However, on OpenBSD,
man errno|egrep ' [0-9]+ E[A-Z]+'|sed 's/^ *//'|cut -d' ' -f1,2
prints out a nice table of "...\n89 EIDM\n..." that you can convert further into a data structure for the programming language that you'd like to have this function in.