error.h 2.6 KB

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