]> git.saurik.com Git - bison.git/blob - lib/error.h
38a8e2967aa040c52d0ce8bfc5bfa268c3b3ee1e
[bison.git] / lib / error.h
1 /* Declaration for error-reporting function
2 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
3
4
5 NOTE: The canonical source of this file is maintained with the GNU C Library.
6 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
7
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 USA. */
22
23 #ifndef _ERROR_H
24 #define _ERROR_H 1
25
26 #ifndef __attribute__
27 /* This feature is available in gcc versions 2.5 and later. */
28 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
29 # define __attribute__(Spec) /* empty */
30 # endif
31 /* The __-protected variants of `format' and `printf' attributes
32 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
33 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
34 # define __format__ format
35 # define __printf__ printf
36 # endif
37 #endif
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #if defined (__STDC__) && __STDC__
44
45 /* Print a message with `fprintf (stderr, FORMAT, ...)';
46 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
47 If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
48
49 extern void error (int status, int errnum, const char *format, ...)
50 __attribute__ ((__format__ (__printf__, 3, 4)));
51
52 extern void error_at_line (int status, int errnum, const char *fname,
53 unsigned int lineno, const char *format, ...)
54 __attribute__ ((__format__ (__printf__, 5, 6)));
55
56 /* If NULL, error will flush stdout, then print on stderr the program
57 name, a colon and a space. Otherwise, error will call this
58 function without parameters instead. */
59 extern void (*error_print_progname) (void);
60
61 #else
62 void error ();
63 void error_at_line ();
64 extern void (*error_print_progname) ();
65 #endif
66
67 /* This variable is incremented each time `error' is called. */
68 extern unsigned int error_message_count;
69
70 /* Sometimes we want to have at most one error per line. This
71 variable controls whether this mode is selected or not. */
72 extern int error_one_per_line;
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* error.h */
79 /* Declaration for error-reporting function
80 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
81
82
83 NOTE: The canonical source of this file is maintained with the GNU C Library.
84 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
85
86 This program is free software; you can redistribute it and/or modify it
87 under the terms of the GNU General Public License as published by the
88 Free Software Foundation; either version 2, or (at your option) any
89 later version.
90
91 This program is distributed in the hope that it will be useful,
92 but WITHOUT ANY WARRANTY; without even the implied warranty of
93 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94 GNU General Public License for more details.
95
96 You should have received a copy of the GNU General Public License
97 along with this program; if not, write to the Free Software
98 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
99 USA. */
100
101 #ifndef _ERROR_H
102 #define _ERROR_H 1
103
104 #ifndef __attribute__
105 /* This feature is available in gcc versions 2.5 and later. */
106 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
107 # define __attribute__(Spec) /* empty */
108 # endif
109 /* The __-protected variants of `format' and `printf' attributes
110 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
111 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
112 # define __format__ format
113 # define __printf__ printf
114 # endif
115 #endif
116
117 #ifdef __cplusplus
118 extern "C" {
119 #endif
120
121 #if defined (__STDC__) && __STDC__
122
123 /* Print a message with `fprintf (stderr, FORMAT, ...)';
124 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
125 If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
126
127 extern void error (int status, int errnum, const char *format, ...)
128 __attribute__ ((__format__ (__printf__, 3, 4)));
129
130 extern void error_at_line (int status, int errnum, const char *fname,
131 unsigned int lineno, const char *format, ...)
132 __attribute__ ((__format__ (__printf__, 5, 6)));
133
134 /* If NULL, error will flush stdout, then print on stderr the program
135 name, a colon and a space. Otherwise, error will call this
136 function without parameters instead. */
137 extern void (*error_print_progname) (void);
138
139 #else
140 void error ();
141 void error_at_line ();
142 extern void (*error_print_progname) ();
143 #endif
144
145 /* This variable is incremented each time `error' is called. */
146 extern unsigned int error_message_count;
147
148 /* Sometimes we want to have at most one error per line. This
149 variable controls whether this mode is selected or not. */
150 extern int error_one_per_line;
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif /* error.h */