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

XUngrabDeviceButton(3) - grab/ungrab extension input device
The XGrabDeviceButton request establishes a passive grab. In the future, the device is actively grabbed (as for XGrabDevice, the last-grab time is set to the ti

glutJoystickFunc(3) - sets the joystick callback for the cur
glutJoystickFunc sets the joystick callback for the current window. The joystick callback is called either due to polling of the joystick at the uniform timer i

asinf(3) - arc sine function (Library - Linux man page).....
The asin() function calculates the principal value of the arc sine of x; that is the value whose sine is x. RETURN VALUE On success, these functions return the

glRasterPos2fv(3gl) - specify the raster position for pixel
The GL maintains a 3D position in window coordinates. This position, called the raster position, is used to position pixel and bitmap write operations. It is ma

mvinsch(3ncurses) - insert a character before cursor in a cu
These routines insert the character ch before the character under the cursor. All characters to the right of the cursor are moved one space to the right, with t

BlackPixelOfScreen(3) - screen information functions and mac
The BlackPixelOfScreen macro returns the black pixel value of the specified screen. The WhitePixelOfScreen macro returns the white pixel value of the specified

Date::Language::Hungarian(3pm) - Magyar format for Date::For
my $lang = Date::Language&gt;new(&#039;Hungarian&#039;); print $lang&gt;time2str(&quot;%a %b %e %T %Y&quot;, time); @lt = localtime(time); print $lang&gt;time2str($template, time); print

MB_CUR_MAX(3) - maximum length of a multibyte character in t
The MB_CUR_MAX macro defines an integer expression giving the maximum number of bytes needed to represent a single wide character in the current locale. It is l

format(n) - Format a string in the style of sprintf.........
This command generates a formatted string in a fashion similar to the ANSI C sprintf procedure. FormatString indicates how to format the result, using % convers

ip-mroute(8) multicast routing cache management (Man Page)
mroute objects are multicast routing cache entries created by a user-level mrouting daemon (f.e. pimd or mrouted ). Due to the limitations of the current interf

Tk_InternalBorderRight(3) - retrieve information from Tk's l
Tk_WindowId and the other names listed above are all macros that return fields from Tks local data structure for tkwin. None of these macros requires any intera

XAllocColor(3) - allocate and free colors - Linux man page
The XAllocColor function allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware. XAllocColor returns the pixel va

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