1ERROR(3)                   Linux Programmer's Manual                  ERROR(3)
2
3
4

NAME

6       error,     error_at_line,    error_message_count,    error_on_per_line,
7       error_print_progname - glibc error reporting functions
8

SYNOPSIS

10       #include <error.h>
11
12       void error(int status, int errnum, const char *format, ...);
13
14       void error_at_line(int status, int errnum, const char *filename,
15                          unsigned int linenum, const char *format, ...);
16
17       extern unsigned int error_message_count;
18
19       extern int error_one_per_line;
20
21       extern void (* error_print_progname) (void);
22

DESCRIPTION

24       error() is a general error reporting function.  It flushes stdout,  and
25       then  outputs to stderr the program name, a colon and a space, the mes‐
26       sage specified by the printf(3)-style format  string  format,  and,  if
27       errnum  is  nonzero,  a second colon and a space followed by the string
28       given by perror(errnum).  Any arguments required for format should fol‐
29       low format in the argument list.  The output is terminated by a newline
30       character.
31
32       The program name printed by error() is the value of the global variable
33       program_invocation_name(3).   program_invocation_name initially has the
34       same value as main()'s argv[0].  The value of this variable can be mod‐
35       ified to change the output of error().
36
37       If  status has a nonzero value, then error() calls exit(3) to terminate
38       the program using the given value as the exit status.
39
40       The error_at_line() function is exactly the same as error(), except for
41       the  addition  of  the arguments filename and linenum.  The output pro‐
42       duced is as for error(), except that after the program name  are  writ‐
43       ten: a colon, the value of filename, a colon, and the value of linenum.
44       The preprocessor values __LINE__ and __FILE__ may be useful when  call‐
45       ing  error_at_line(),  but other values can also be used.  For example,
46       these arguments could refer to a location in an input file.
47
48       If the global variable error_one_per_line is set nonzero, a sequence of
49       error_at_line()  calls with the same value of filename and linenum will
50       result in only one message (the first) being output.
51
52       The global variable error_message_count counts the number  of  messages
53       that have been output by error() and error_at_line().
54
55       If  the global variable error_print_progname is assigned the address of
56       a function (i.e., is not NULL), then that function is called instead of
57       prefixing  the  message  with the program name and colon.  The function
58       should print a suitable string to stderr.
59

CONFORMING TO

61       These functions and variables are GNU extensions,  and  should  not  be
62       used in programs intended to be portable.
63

SEE ALSO

65       err(3),  errno(3), exit(3), perror(3), program_invocation_name(3), str‐
66       error(3)
67

COLOPHON

69       This page is part of release 3.25 of the Linux  man-pages  project.   A
70       description  of  the project, and information about reporting bugs, can
71       be found at http://www.kernel.org/doc/man-pages/.
72
73
74
75GNU                               2006-04-25                          ERROR(3)
Impressum