From 26885c50919a81b28868ea133ece004c0a1ec491 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 13 Oct 2015 14:57:48 +0200 Subject: info: errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- doc/info/chap/error-reporting.texinfo | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 doc/info/chap/error-reporting.texinfo (limited to 'doc/info/chap') diff --git a/doc/info/chap/error-reporting.texinfo b/doc/info/chap/error-reporting.texinfo new file mode 100644 index 0000000..08571cd --- /dev/null +++ b/doc/info/chap/error-reporting.texinfo @@ -0,0 +1,53 @@ +@node Error reporting +@chapter Error reporting + +Many functions, especially those involving +system calls, detect and report exceptional +conditions, including error conditions and +interruptions. Exception conditions must often +be checked and handled, often by retrying, +doing something else, or reporting the error +to the user and exit. + +Unless otherwise specified, exceptional +conditions are reporting using the facilities +described in this chapter. + + +@menu +* Error checking:: Checking whether an exception condition occurred. +@end menu + + + +@node Error checking +@section Error checking + +@cpindex Checking for errors +@cpindex Errors checking +@cpindex Exception checking +Most functions return a sentinel value when an +exceptional condition occurs, typically a negative +value (actually @code{-1}), a constant such as +@code{EOF}, or @code{NULL}. This return value only +tells you that an exeception condition has occurred. + +@hfindex errno.h +@lvindex errno +By including the header file @file{}, the +modifiable lvalue @code{errno} is made available. +@sc{ISO}@tie{}C specifies that @code{errno} is not +necessarily a variable, but rather just an modifiable +lvalue. In fact, must @code{libc}:s, including +@code{slibc} defines it as a macro that calls a +function and uses the unary @code{*}-operator on the +return. + +@code{errno} is often thought of as a variable +declared as @code{int errno}, or @code{volatile int errno}. +But the value is thread-local, and is thus more +like @code{_Thread_local volatile int errno}. Because +of this, the @code{errno} is defined as a macro that +calls a function. Otherwise, it would not be implementable +without @sc{ISO}@tie{}C11. + -- cgit v1.2.3-70-g09d2