c++cerror-handlingstandard-libraryerrno

Where can I see the list of functions that interact with errno?


In the book "The C Programming Language" it says:

"Many of the functions in the library set status indicators when error or end of file occur. These indicators may be set and tested explicitly. In addition, the integer expression errno (declared in <errno.h>) may contain an error number that gives further information about the most recent error."

Where can I see a list of these functions?


Solution

  • The standard says this about errno:

    The value of errno is zero at program startup, but is never set to zero by any library function. The value of errno may be set to nonzero by a library function call whether or not there is an error, provided the use of errno is not documented in the description of the function in this International Standard.

    Which says to me that any library function can screw around with errno in any way it likes except:

    Note that the standard suggests the following in a footnote:

    Thus, a program that uses errno for error checking should set it to zero before a library function call, then inspect it before a subsequent library function call. Of course, a library function can save the value of errno on entry and then set it to zero, as long as the original value is restored if errno's value is still zero just before the return.

    As noted in other answers, it's common for functions that are not in the standard to set errno as well.