1ASSERT_PERROR(3) Linux Programmer's Manual ASSERT_PERROR(3)
2
3
4
6 assert_perror - test errnum and abort
7
9 #define _GNU_SOURCE
10 #include <assert.h>
11
12 void assert_perror(int errnum);
13
15 If the macro NDEBUG was defined at the moment <assert.h> was last
16 included, the macro assert_perror() generates no code, and hence does
17 nothing at all. Otherwise, the macro assert_perror() prints an error
18 message to standard error and terminates the program by calling abort()
19 if errnum is non-zero. The message contains the filename, function name
20 and line number of the macro call, and the output of strerror(errnum).
21
23 No value is returned.
24
26 This is a GNU extension.
27
29 The purpose of the assert macros is to help the programmer find bugs in
30 his program, things that cannot happen unless there was a coding mis‐
31 take. However, with system or library calls the situation is rather
32 different, and error returns can happen, and will happen, and should be
33 tested for. Not by an assert, where the test goes away when NDEBUG is
34 defined, but by proper error handling code. Never use this macro.
35
37 abort(3), assert(3), exit(3), strerror(3), feature_test_macros(7)
38
39
40
41GNU 2002-08-25 ASSERT_PERROR(3)