Hi Bruce, > This isn't a library function, but a program that I needed to polish up a bit. > Fiddling and tweaking can turn it into a library function without too much > trouble. > The last file ("err-names.h") is a derived file that depends on the "mk" > script
Is the list of errno values meant to be extracted before a tarball is built, or at build time? If you want to create a distributable file, IMO Thien-Thi Nguyen's approach [1] is good. The code would then look similar to lib/strerror-override.c, basically like this: #ifdef ENOENT case ENOENT: return "ENOENT"; #endif #ifdef ENOTDIR case ENOTDIR: return "ENOTDIR"; #endif ... If you want to create file at build time, then the mk-err-names.sh script needs to be a /bin/sh script; you cannot assume that 'bash' is available. Also, what's the point of using the numeric values of the error numbers? If you generate code like case ENOENT: return "ENOENT"; case ENOTDIR: return "ENOTDIR"; ... then the code is not only more robust but also requires fewer relocations when put into a shared library. In [ 1] = "EPERM", [ 2] = "ENOENT", the shared library needs to relocate, during loading, as many pointers as there are references to strings. See Ulrich Drepper's writeup about how to code for shared libraries ([2], section 2.4.3). Bruno [1] http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00057.html [2] http://www.akkadia.org/drepper/dsohowto.pdf -- In memoriam Amatore Sciesa <http://it.wikipedia.org/wiki/Amatore_Sciesa>