HOME

TheInfoList



OR:

errno.h is a
header file Many programming languages and other computer files have a directive, often called include (sometimes copy or import), that causes the contents of the specified file to be inserted into the original file. These included files are called copybooks ...
in the
standard library In computer programming, a standard library is the library made available across implementations of a programming language. These libraries are conventionally described in programming language specifications; however, contents of a language's a ...
of the
C programming language ''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well a ...
. It defines macros for reporting and retrieving error conditions using the symbol errno (short 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 NULL for functions that return pointers, and -1 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 The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard. ISO/IEC (2018). '' ISO/IEC 9899:2018(E): Programming Languages - C ยง7'' Starting from the original ANSI C standard, it was ...
only requires three to be defined: EDOM :Results from a parameter outside a function's domain, e.g. ERANGE :Results from a result outside a function's range, e.g. on systems with a 32-bit wide long EILSEQ (Required since 1994 Amendment 1 to C89 standard) :Results from an illegal byte sequence, e.g. on systems that use
UTF-8 UTF-8 is a variable-length character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode'' (or ''Universal Coded Character Set'') ''Transformation Format 8-bit''. UTF-8 is capable of e ...
.
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming in ...
compliant
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s like
AIX Aix or AIX may refer to: Computing * AIX, a line of IBM computer operating systems *An Alternate Index, for a Virtual Storage Access Method Key Sequenced Data Set * Athens Internet Exchange, a European Internet exchange point Places Belgiu ...
,
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, whi ...
or Solaris include many other error values, many of which are used much more often than the above ones, such as EACCES for when a file cannot be opened for reading.
C++11 C11, C.XI, C-11 or C.11 may refer to: Transport * C-11 Fleetster, a 1920s American light transport aircraft for use of the United States Assistant Secretary of War * Fokker C.XI, a 1935 Dutch reconnaissance seaplane * LET C-11, a license-build ...
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 Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, whi ...
, where these macros are instead listed in the errno(3). An can be translated to a descriptive string using
strerror The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. F ...
(defined in string.h) or a BSD extension called . The translation can be printed directly to the
standard error stream In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdi ...
using perror (defined in stdio.h). 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.


See also

* perror *
strerror The C programming language has a set of functions implementing operations on strings (character strings and byte strings) in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. F ...


References


Bibliography

*


External links

* *{{man, 3, errno, Linux
GNU C library manual: Error codes
C standard library headers