ANSI Error Message Function
void error(int status, int errnum, const char *format, ...);
Internationalization (I18n) Function Overview
The error function is used to report general problems during program execution. The format argument is a format string just like those given to the printf family of functions. The arguments required for the format follow the format parameter.
Just like perror , error also can report an error code in textual form. But unlike perror the error value is explicitly passed to the function in the errnum parameter. This eliminates the problem that the error reporting function must be called immediately after the function causing the error since otherwise errno might have a different value.
The output is directed to the stderr stream. Note that if stderr wasn't oriented before the call it will be narrow-oriented afterwards.
The function will return unless the status parameter has a non-zero value. In this case the function will call exit with the status value for its parameter and therefore never return. If error returns the global variable error_message_count is incremented by one to keep track of the number of errors reported.
For more on functions that print error messages, see Error Reporting in the GNU manual.
I18n Issues
This function should not be relied upon to print error messages in any language other than English, and therefore should be avoided in an internationalized application. However, its worth noting that in some limited instances it still may be useful. For example, for debugging, or for writing to log files that will not be viewed by the end user.
Prior to calling this function, ensure that the current locale is set properly by calling setlocale, as string formatting is dependent on the LC_NUMERIC locale category.
See String Formatting in C and C++ for a discussion on locale-sensitive formatting in internationalized applications.
There is no ANSI wide character version of this function. The parameters will have to be converted to multibyte UTF-8 characters and then the error function can be used.
Recommended Replacements*
*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.
ANSI Error Message Functions
|