1*4882a593Smuzhiyun /* error.h -- declaration for error-reporting function 2*4882a593Smuzhiyun Copyright (C) 1995, 1996 Free Software Foundation, Inc. 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun This program is free software; you can redistribute it and/or modify 5*4882a593Smuzhiyun it under the terms of the GNU General Public License as published by 6*4882a593Smuzhiyun the Free Software Foundation; either version 2, or (at your option) 7*4882a593Smuzhiyun any later version. 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun This program is distributed in the hope that it will be useful, 10*4882a593Smuzhiyun but WITHOUT ANY WARRANTY; without even the implied warranty of 11*4882a593Smuzhiyun MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*4882a593Smuzhiyun GNU General Public License for more details. 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun You should have received a copy of the GNU General Public License 15*4882a593Smuzhiyun along with this program; if not, write to the Free Software 16*4882a593Smuzhiyun Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun #ifndef _error_h_ 19*4882a593Smuzhiyun #define _error_h_ 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun #ifndef __attribute__ 22*4882a593Smuzhiyun /* This feature is available in gcc versions 2.5 and later. */ 23*4882a593Smuzhiyun # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ 24*4882a593Smuzhiyun # define __attribute__(Spec) /* empty */ 25*4882a593Smuzhiyun # endif 26*4882a593Smuzhiyun /* The __-protected variants of `format' and `printf' attributes 27*4882a593Smuzhiyun are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ 28*4882a593Smuzhiyun # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 29*4882a593Smuzhiyun # define __format__ format 30*4882a593Smuzhiyun # define __printf__ printf 31*4882a593Smuzhiyun # endif 32*4882a593Smuzhiyun #endif 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun #if defined (__STDC__) && __STDC__ 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* Print a message with `fprintf (stderr, FORMAT, ...)'; 37*4882a593Smuzhiyun if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). 38*4882a593Smuzhiyun If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun extern void error (int status, int errnum, const char *format, ...) 41*4882a593Smuzhiyun __attribute__ ((__format__ (__printf__, 3, 4))); 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun extern void error_at_line (int status, int errnum, const char *fname, 44*4882a593Smuzhiyun unsigned int lineno, const char *format, ...) 45*4882a593Smuzhiyun __attribute__ ((__format__ (__printf__, 5, 6))); 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun /* If NULL, error will flush stdout, then print on stderr the program 48*4882a593Smuzhiyun name, a colon and a space. Otherwise, error will call this 49*4882a593Smuzhiyun function without parameters instead. */ 50*4882a593Smuzhiyun extern void (*error_print_progname) (void); 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun #else 53*4882a593Smuzhiyun void error (); 54*4882a593Smuzhiyun void error_at_line (); 55*4882a593Smuzhiyun extern void (*error_print_progname) (); 56*4882a593Smuzhiyun #endif 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* This variable is incremented each time `error' is called. */ 59*4882a593Smuzhiyun extern unsigned int error_message_count; 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun /* Sometimes we want to have at most one error per line. This 62*4882a593Smuzhiyun variable controls whether this mode is selected or not. */ 63*4882a593Smuzhiyun extern int error_one_per_line; 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun #endif /* _error_h_ */ 66