OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / original / man3 / assert_perror.3
1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" This replaces an earlier man page written by Walter Harms
24 .\" <walter.harms@informatik.uni-oldenburg.de>.
25 .\"
26 .TH ASSERT_PERROR 3  2002-08-25 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 assert_perror \- test errnum and abort
29 .SH SYNOPSIS
30 .nf
31 .B #define _GNU_SOURCE
32 .B #include <assert.h>
33 .sp
34 .BI "void assert_perror(int " errnum );
35 .fi
36 .SH DESCRIPTION
37 If the macro
38 .B NDEBUG
39 was defined at the moment
40 .I <assert.h>
41 was last included, the macro
42 .BR assert_perror ()
43 generates no code, and hence does nothing at all.
44 Otherwise, the macro
45 .BR assert_perror ()
46 prints an error message to standard error and terminates the program
47 by calling
48 .BR abort (3)
49 if
50 .I errnum
51 is nonzero.
52 The message contains the filename, function name and
53 line number of the macro call, and the output of
54 .IR strerror(errnum) .
55 .SH "RETURN VALUE"
56 No value is returned.
57 .SH "CONFORMING TO"
58 This is a GNU extension.
59 .SH BUGS
60 The purpose of the assert macros is to help the programmer find bugs in
61 his program, things that cannot happen unless there was a coding mistake.
62 However, with system or library calls the situation is rather different,
63 and error returns can happen, and will happen, and should be tested for.
64 Not by an assert, where the test goes away when
65 .B NDEBUG
66 is defined,
67 but by proper error handling code.
68 Never use this macro.
69 .SH "SEE ALSO"
70 .BR abort (3),
71 .BR assert (3),
72 .BR exit (3),
73 .BR strerror (3),
74 .BR feature_test_macros (7)