C Library - <errno.h>

Advertisements


Introduction

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, and certain functions of the standard C library modify its value to some value different from 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 shall expand to integer constant expressions with type int.

Library Macros

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

S.N.Macro & Description
1extern 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.
2EDOM 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.
3ERANGE 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
Advertisements