1assert_perror(3) Library Functions Manual assert_perror(3)
2
3
4
6 assert_perror - test errnum and abort
7
9 Standard C library (libc, -lc)
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <assert.h>
14
15 void assert_perror(int errnum);
16
18 If the macro NDEBUG was defined at the moment <assert.h> was last in‐
19 cluded, the macro assert_perror() generates no code, and hence does
20 nothing at all. Otherwise, the macro assert_perror() prints an error
21 message to standard error and terminates the program by calling
22 abort(3) if errnum is nonzero. The message contains the filename,
23 function name and line number of the macro call, and the output of str‐
24 error(errnum).
25
27 No value is returned.
28
30 For an explanation of the terms used in this section, see at‐
31 tributes(7).
32
33 ┌────────────────────────────────────────────┬───────────────┬─────────┐
34 │Interface │ Attribute │ Value │
35 ├────────────────────────────────────────────┼───────────────┼─────────┤
36 │assert_perror() │ Thread safety │ MT-Safe │
37 └────────────────────────────────────────────┴───────────────┴─────────┘
38
40 GNU.
41
43 The purpose of the assert macros is to help programmers find bugs in
44 their programs, things that cannot happen unless there was a coding
45 mistake. However, with system or library calls the situation is rather
46 different, and error returns can happen, and will happen, and should be
47 tested for. Not by an assert, where the test goes away when NDEBUG is
48 defined, but by proper error handling code. Never use this macro.
49
51 abort(3), assert(3), exit(3), strerror(3)
52
53
54
55Linux man-pages 6.04 2023-03-30 assert_perror(3)