Use system assert instead of homegrown Assert
This commit is contained in:
parent
56fdec73cd
commit
e678948dda
|
@ -21,6 +21,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#define _ERROR_H
|
#define _ERROR_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define __noreturn __attribute__ ((noreturn))
|
#define __noreturn __attribute__ ((noreturn))
|
||||||
|
@ -35,10 +36,8 @@ int error_init(void (*func)(const char *)); //init error system, returns 0=ok
|
||||||
void Warning(char *fmt,...); //print out warning message to user
|
void Warning(char *fmt,...); //print out warning message to user
|
||||||
void set_warn_func(void (*f)(char *s));//specifies the function to call with warning messages
|
void set_warn_func(void (*f)(char *s));//specifies the function to call with warning messages
|
||||||
void clear_warn_func(void (*f)(char *s));//say this function no longer valid
|
void clear_warn_func(void (*f)(char *s));//say this function no longer valid
|
||||||
void _Assert(int expr,char *expr_text,char *filename,int linenum); //assert func
|
|
||||||
void Error(const char *fmt,...) __noreturn __attribute_gcc_format((printf, 1, 2)); //exit with error code=1, print message
|
void Error(const char *fmt,...) __noreturn __attribute_gcc_format((printf, 1, 2)); //exit with error code=1, print message
|
||||||
void Assert(int expr);
|
#define Assert assert
|
||||||
void Int3();
|
|
||||||
#ifndef NDEBUG //macros for debugging
|
#ifndef NDEBUG //macros for debugging
|
||||||
|
|
||||||
# if defined(__APPLE__) || defined(macintosh)
|
# if defined(__APPLE__) || defined(macintosh)
|
||||||
|
@ -47,12 +46,10 @@ extern void Debugger(void); // Avoids some name clashes
|
||||||
# else
|
# else
|
||||||
# define Int3() ((void)0)
|
# define Int3() ((void)0)
|
||||||
# endif // Macintosh
|
# endif // Macintosh
|
||||||
#define Assert(expr) ((expr)?(void)0:(void)_Assert(0,#expr,__FILE__,__LINE__))
|
|
||||||
|
|
||||||
#else //macros for real game
|
#else //macros for real game
|
||||||
|
|
||||||
//Changed Assert and Int3 because I couldn't get the macros to compile -KRB
|
//Changed Assert and Int3 because I couldn't get the macros to compile -KRB
|
||||||
#define Assert(__ignore) ((void)0)
|
|
||||||
#define Int3() ((void)0)
|
#define Int3() ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,6 @@ void clear_warn_func(void (*f)(char *s))
|
||||||
warn_func = warn_printf;
|
warn_func = warn_printf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Assert(int expr,char *expr_text,char *filename,int linenum)
|
|
||||||
{
|
|
||||||
Int3();
|
|
||||||
if (!(expr)) Error("Assertion failed: %s, file %s, line %d",expr_text,filename,linenum);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_exit_message(const char *exit_message)
|
void print_exit_message(const char *exit_message)
|
||||||
{
|
{
|
||||||
if (ErrorPrintFunc)
|
if (ErrorPrintFunc)
|
||||||
|
|
Loading…
Reference in a new issue