is a header file in the standard library of the C programming language. It defines macros for reporting and retrieving error conditions using the symbol errno (short form for "error number").International Standard for Programming Language C (C11), ISO/IEC 9899:2011, p. 205

errno acts like an integer variable. A value (the error number) is stored in errno by certain library functions when they detect errors. At program startup, the value stored is zero. Library functions store only values greater than zero. Any library function can alter the value stored before return, whether or not they detect errors.International Standard for Programming Language C (C99), ISO/IEC 9899:1999, p. 186 Most functions indicate that they detected an error by returning a special value, typically for functions that return pointers, and for functions that return integers. A few functions require the caller to preset errno to zero and test it afterwards to see if an error was detected.

The errno macro expands to an lvalue with type int, sometimes with the extern and/or volatile type specifiers depending upon the platform. Originally this was a static memory location, but macros are almost always used today to allow for multi-threading, so that each thread will see its own thread-local error number.

The header file also defines macros that expand to integer constants that represent the error codes. The C standard library only requires three to be defined:

A parameter was outside a function's domain, e.g. A result outside a function's range, e.g. on systems with a 32-bit wide long (Required since 1994 Amendment 1 to C89 standard)Illegal byte sequence, e.g. on systems that use UTF-8.

POSIX compliant operating systems like AIX, Linux or Solaris include many other error values, many of which are used much more often than the above ones, such as for when a file cannot be opened for reading. C++11 additionally defines many of the same values found within the POSIX specification.

Traditionally, the first page of Unix system manuals, named intro(2), lists all errno.h macros, but this is not the case with Linux, where these macros are instead listed in the errno(3).

An can be translated to a descriptive string using (defined in ) or a BSD extension called . The translation can be printed directly to the standard error stream using (defined in ). As in many Unix-like systems is not thread-safe, a thread-safe version is used, but conflicting definitions from POSIX and GNU makes it even less portable than the table.

POSIX errors

The GNU C library (GLIBC) provides the additional POSIX error values macros in the header file . These are the descriptions of the macros provided by .FreeBSD System: Error codes

Symbol Value Description Operation not permitted No such file or directory No such process Interrupted system call Input/output error No such device or address Argument list too long Exec format error Bad file descriptor No child processes Resource temporarily unavailable Cannot allocate memory Permission denied Bad address Block device required Device or resource busy File exists Invalid cross-device link No such device Not a directory Is a directory Invalid argument Too many open files in system Too many open files Inappropriate ioctl for device Text file busy File too large No space left on device Illegal seek Read-only file system Too many links Broken pipe Numerical argument out of domain Numerical result out of range Resource deadlock avoided File name too long No locks available Function not implemented Directory not empty Too many levels of symbolic links No message of desired type Identifier removed Channel number out of range Level 2 not synchronized Level 3 halted Level 3 reset Link number out of range Protocol driver not attached No CSI structure available Level 2 halted Invalid exchange Invalid request descriptor Exchange full No anode Invalid request code Invalid slot Bad font file format Device not a stream No data available Timer expired Out of streams resources Machine is not on the network Package not installed Object is remote Link has been severed Advertise error Srmount error Communication error on send Protocol error Multihop attempted RFS specific error Bad message Value too large to be stored in data type Name not unique on network File descriptor in bad state Remote address changed Can not access a needed shared library Accessing a corrupted shared library section in corrupted Attempting to link in too many shared libraries Cannot exec a shared library directly Illegal byte sequence Interrupted system call should be restarted Streams pipe error Too many users Socket operation on non-socket Destination address required Message too long Protocol wrong type for socket Protocol not available Protocol not supported Socket type not supported Operation not supported Protocol family not supported Address family not supported by protocol Address already in use Cannot assign requested address Network is down Network is unreachable Network dropped connection on reset Software caused connection abort Connection reset by peer No buffer space available. This condition caused by lack of memory in the OS's buffers. Transport endpoint is already connected Transport endpoint is not connected Cannot send after transport endpoint shutdown Too many references: cannot splice Connection timed out Connection refused Host is down No route to host Operation already in progress Operation now in progress Stale file handle Structure needs cleaning Not a Xenix named type file No Xenix semaphores available Is a named type file Remote I/O error Disk quota exceeded No medium found Wrong medium type Operation canceled Required key not available Key has expired Key has been revoked Key was rejected by service Previous owner died State not recoverable Operation not possible due to RF-kill Memory page has hardware error Not supported parameter or option

The macro names and meanings for error codes are defined in the POSIX Standards definition however the numeric values are NOT, though by convention the values appear to be the same across different versions of Unix. Programs should not rely on specific numeric values and should test code using the macro names specified in the ERRORS section of the man page of the associated function. For source code readability and portability the use of the standard macro names in code is highly recommended.

See also perror strerror

References

Bibliography

External links

GNU C library manual: Error codes Lists of errno values on Linux, both numeric and symbolic