C Library - <errno.h>



The errno.h header file of the C Standard Library defines the integer variable errno, which is set by system calls and some library functions in the event of an error to indicate what went wrong. This macro expands to a modifiable lvalue of type int, therefore it can be both read and modified by a program.

The errno is set to zero at program startup. Certain functions of the standard C library modify its value to other than zero to signal some types of error. You can also modify its value or reset to zero at your convenience.

The errno.h header file also defines a list of macros indicating different error codes, which will expand to integer constant expressions with type int.

Library Macros

Following are the macros defined in the header errno.h −

Sr.No. Macro & Description
1 extern int errno

This is the macro set by system calls and some library functions in the event of an error to indicate what went wrong.

2 EDOM Domain Error

This macro represents a domain error, which occurs if an input argument is outside the domain, over which the mathematical function is defined and errno is set to EDOM.

3 ERANGE Range Error

This macro represents a range error, which occurs if an input argument is outside the range, over which the mathematical function is defined and errno is set to ERANGE.

Advertisements