Errno.h

Uses your system voice; voice and rate in settings.

Snapshot

≈ 4 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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"). 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. 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.…

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"). 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. 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: 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.

References

External links

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

Text derived from https://en.wikipedia.org/w/index.php?oldid=1377122775 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

8 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.