The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


errno - XSI error return value


#include <errno.h>


errno is used by many XSI functions to return error values.

Many functions provide an error number in errno which has type int and is defined in <errno.h>. The value of errno will be defined only after a call to a function for which it is explicitly stated to be set and until it is changed by the next function call. The value of errno should only be examined when it is indicated to be valid by a function's return value. Programs should obtain the definition of errno by the inclusion of <errno.h>. The practice of defining errno in a program as extern int errno is obsolescent. No function in this specification sets errno to 0 to indicate an error.

It is unspecified whether errno is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name errno, the behaviour is undefined.

The symbolic values stored in errno are documented in the ERRORS sections on all relevant pages.








Previously both POSIX and X/Open documents were more restrictive than the ISO C standard in that they required errno to be defined as an external variable, whereas the ISO C standard required only that errno be defined as a modifiable lvalue with type int.

A program that uses errno for error checking should set it to 0 before a function call, then inspect it before a subsequent function call.




<errno.h>, errors.


Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]