1 /* $Id: error.h,v 1.12 2004-08-28 23:17:45 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Header for error handling/printing/exiting code
27 #define __noreturn __attribute__ ((noreturn))
28 #define __format __attribute__ ((format (printf, 1, 2)))
34 int error_init(void (*func)(char *), char *fmt,...); //init error system, set default message, returns 0=ok
35 void set_exit_message(char *fmt,...); //specify message to print at exit
36 void Warning(char *fmt,...); //print out warning message to user
37 void set_warn_func(void (*f)(char *s));//specifies the function to call with warning messages
38 void clear_warn_func(void (*f)(char *s));//say this function no longer valid
39 void _Assert(int expr,char *expr_text,char *filename,int linenum); //assert func
40 void Error(char *fmt,...) __noreturn __format; //exit with error code=1, print message
41 void Assert(int expr);
43 #ifndef NDEBUG //macros for debugging
46 # if defined(__APPLE__) || defined(macintosh)
47 extern void Debugger(void); // Avoids some name clashes
48 # define Int3 Debugger
50 //# define Int3() Error("int 3 %s:%i\n",__FILE__,__LINE__);
51 //# define Int3() {volatile int a=0,b=1/a;}
52 # define Int3() ((void)0)
62 static inline void _Int3()
64 if (FindArg("-debug")) {
66 SDL_WM_GrabInput(SDL_GRAB_OFF);
71 #define Int3() _Int3()
73 #elif defined __WATCOMC__
74 void Int3(void); //generate int3
75 #pragma aux Int3 = "int 3h";
77 #elif defined _MSC_VER
78 static __inline void _Int3()
82 #define Int3() _Int3()
85 #error Unknown Compiler!
90 #define Assert(expr) ((expr)?(void)0:(void)_Assert(0,#expr,__FILE__,__LINE__))
93 //#define Error(format, args...) ({ /*Int3();*/ Error(format , ## args); })
94 #elif defined __WATCOMC__
95 //make error do int3, then call func
96 #pragma aux Error aborts = \
100 //#pragma aux Error aborts;
102 // DPH: I'm not going to bother... it's not needed... :-)
106 //make assert do int3 (if expr false), then call func
107 #pragma aux _Assert parm [eax] [edx] [ebx] [ecx] = \
115 #else //macros for real game
118 #pragma aux Error aborts;
120 //Changed Assert and Int3 because I couldn't get the macros to compile -KRB
121 #define Assert(__ignore) ((void)0)
122 //void Assert(int expr);
123 #define Int3() ((void)0)
127 #endif /* _ERROR_H */