error, error_at_line, error_message_count, error_one_per_line, error_print_progname − glibc error reporting functions


#include <error.h>

void error(int status, int errnum, const char *format, ...);

void error_at_line(int status, int errnum, const char *filename,
unsigned int
linenum, const char *format, ...);

extern unsigned int error_message_count;

extern int error_one_per_line;

extern void (*error_print_progname) (void);


error() is a general error-reporting function. It flushes stdout, and then outputs to stderr the program name, a colon and a space, the message specified by the printf(3)-style format string format, and, if errnum is nonzero, a second colon and a space followed by the string given by strerror(errnum). Any arguments required for format should follow format in the argument list. The output is terminated by a newline character.

The program name printed by error() is the value of the global variable program_invocation_name(3). program_invocation_name initially has the same value as main()’s argv[0]. The value of this variable can be modified to change the output of error().

If status has a nonzero value, then error() calls exit(3) to terminate the program using the given value as the exit status.

The error_at_line() function is exactly the same as error(), except for the addition of the arguments filename and linenum. The output produced is as for error(), except that after the program name are written: a colon, the value of filename, a colon, and the value of linenum. The preprocessor values __LINE__ and __FILE__ may be useful when calling error_at_line(), but other values can also be used. For example, these arguments could refer to a location in an input file.

If the global variable error_one_per_line is set nonzero, a sequence of error_at_line() calls with the same value of filename and linenum will result in only one message (the first) being output.

The global variable error_message_count counts the number of messages that have been output by error() and error_at_line().

If the global variable error_print_progname is assigned the address of a function (i.e., is not NULL), then that function is called instead of prefixing the message with the program name and colon. The function should print a suitable string to stderr.


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


err(3), errno(3), exit(3), perror(3), program_invocation_name(3), strerror(3)


This page is part of release 3.69 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at−pages/.

More Linux Commands

xdrrec_create(3) - library routines for external data repres
These routines allow C programmers to describe arbitrary data structures in a machine-independent fashion. Data for remote procedure calls are transmitted using

xzdec(1) - Small .xz and .lzma decompressors (Man Page).....
xzdec is a liblzma-based decompression-only tool for .xz (and only .xz) files. xzdec is intended to work as a drop-in replacement for xz(1) in the most common s

regcomp(3) - POSIX regex functions - Linux manual page......
POSIX regex compiling regcomp() is used to compile a regular expression into a form that is suitable for subsequent regexec() searches. regcomp() is supplied wi

set_field_buffer(3form) - field buffer control (Man Page)...
The function set_field_buffer sets the numbered buffer of the given field to contain a given string: * Buffer 0 is the displayed value of the field. * Other num

gnutls_x509_crt_set_subject_alt_name(3) - API function......
gnutls_x509_crt_set_subject_alt_name.3 - This function will set the subject alternative name certificate extension. It can set the following types: RETURNS On s

snmpbulkwalk(1) - retrieve a subtree of management values us
snmpbulkwalk is an SNMP application that uses SNMP GETBULK requests to query a network entity efficiently for a tree of information. An object identifier (OID)

killpg(2) - send signal to a process group - Linux man page
killpg() sends the signal sig to the process group pgrp. See signal(7) for a list of signals. If pgrp is 0, killpg() sends the signal to the calling processs pr

hciattach(8) - attach serial devices via UART HCI to BlueZ s
hciattach.8 - Hciattach is used to attach a serial UART to the Bluetooth stack as HCI transport interface. OPTIONS -b Send break. -n Dont detach from controllin

XkbAllocClientMap(3) - Allocate and initialize an empty clie
Calling XkbGetMap should be sufficient for most applications to get client and server maps. As a result, most applications do not need to directly allocate clie

XGCValues(3) - create or free graphics contexts and graphics
The XCreateGC function creates a graphics context and returns a GC. The GC can be used with any destination drawable having the same root and depth as the speci

casinh(3) - complex arc sine hyperbolic - Linux manual page
The casinh() function calculates the complex arc hyperbolic sine of z. If y = casinh(z), then z = csinh(y). The imaginary part of y is chosen in the interval [-

glVertex3f(3gl) - specify a vertex - Linux manual page......
glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon vertices. The current color, normal, and texture coordinates are assoc

We can't live, work or learn in freedom unless the software we use is free.