|
Translating Error-Code Macros to Strings (macrostr.c)The mechanism described here replaces the code shown on p. 27 of the book. Replacing the errcodes array, as shown in the book, is a new array of structures called macrostr_db, which is defined in the file macrostr.c like this: static struct { The ms_code member's values may not be constant, so they're initialized by this function: void macrostr_init(void) The file macrostr1.incl looks like this: {"errno", 0, "EPERM", ""}, ... [rest not shown] and macrostr2.incl looks like this: macrostr_db[0].ms_code = (intptr_t)EPERM; ... [rest not shown] The two "incl" files were produced by the program mkmacrostr.c which takes the text file macrostr.txt as input. Older versions of these files are in the example source archive; the new ones are in a separate archive that you can download from here. |