1assert_perror(3)           Library Functions Manual           assert_perror(3)
2
3
4

NAME

6       assert_perror - test errnum and abort
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #define _GNU_SOURCE         /* See feature_test_macros(7) */
13       #include <assert.h>
14
15       void assert_perror(int errnum);
16

DESCRIPTION

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

RETURN VALUE

27       No value is returned.
28

ATTRIBUTES

30       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
31       tributes(7).
32
33       ┌────────────────────────────────────────────┬───────────────┬─────────┐
34Interface                                   Attribute     Value   
35       ├────────────────────────────────────────────┼───────────────┼─────────┤
36assert_perror()                             │ Thread safety │ MT-Safe │
37       └────────────────────────────────────────────┴───────────────┴─────────┘
38

STANDARDS

40       GNU.
41

BUGS

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

SEE ALSO

51       abort(3), assert(3), exit(3), strerror(3)
52
53
54
55Linux man-pages 6.05              2023-07-20                  assert_perror(3)
Impressum