Whole document tree
    

Whole document tree

A Common Error Description Library for UNIX: Error codes
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 Error codes

Error codes themselves are 32 bit (signed) integers, of which the high order 24 bits are an identifier of which error table the error code is from, and the low order 8 bits are a sequential error number within the table. An error code may thus be easily decomposed into its component parts. Only the lowest 32 bits of an error code are considered significant on systems which support wider values.

Error table 0 is defined to match the UNIX system call error table (sys_errlist); this allows errno values to be used directly in the library (assuming that errno is of a type with the same width as long). Other error table numbers are formed by compacting together the first four characters of the error table name. The mapping between characters in the name and numeric values in the error code are defined in a system-independent fashion, so that two systems that can pass integral values between them can reliably pass error codes without loss of meaning; this should work even if the character sets used are not the same. (However, if this is to be done, error table 0 should be avoided, since the local system call error tables may differ.)

Any variable which is to contain an error code should be declared long. The draft proposed American National Standard for C (as of May, 1988) requires that long variables be at least 32 bits; any system which does not support 32-bit long values cannot make use of this package (nor much other software that assumes an ANSI-C environment base) without significant effort.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Philippe Troin on September, 23 2003 using texi2html