ERRNO(3) Library Functions Manual ERRNO(3)


errnolibrary error result


#include <errno.h>

#define errno <object of thread local storage duration>


The header <errno.h> defines the name errno to refer to an object of thread local storage duration. It is undefined whether or not errno refers to a preprocessor symbol or not.

At program startup, the runtime shall initialize errno to contain the value zero (the initial value in other threads is undefined). It is guaranteed that no function provided by the C standard library shall set the value of errno to zero; therefore, for functions which do not have a unique return value for indicating error, it is possible to determine whether an error occured by setting errno to zero before the call, then after the call seeing if an error value has been stored into errno.

Note that it is valid for any function which is not described as explicitly setting errno to set it to a non-zero value. Checking for a non-zero value is only valid with functions which are defined to modify errno.

In some historical versions of the POSIX standard, the prescribed method of using errno was to define extern int errno. This is no longer supported by the POSIX or C standards, and will not work on the majority of implementations, including this one.


errno.h(3) abort(3) assert(3)


Conforming to ISO/IEC 9899:1990 (“ISO C90”), ISO/IEC 9899:1999 (“ISO C99”).
February 20, 2013 Fusion