OSDN Git Service

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