mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
there is no way something called assert_always should ever be compiled out - people should be able to depend on side effects of something with 'always' in the name
This commit is contained in:
parent
bff99e6130
commit
5ffe5ce551
@ -31,18 +31,44 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
// TODO: make the assert replacement and especially assert_always work again
|
// needed for OSD macros
|
||||||
#include <assert.h>
|
#include "osdcomm.h"
|
||||||
#define assert_always(x, msg) assert(x)
|
|
||||||
|
|
||||||
|
|
||||||
|
//**************************************************************************
|
||||||
|
// EXCEPTION CLASSES
|
||||||
|
//**************************************************************************
|
||||||
|
|
||||||
|
// emu_exception is the base class for all emu-related exceptions
|
||||||
|
class emu_exception : public std::exception { };
|
||||||
|
|
||||||
|
|
||||||
|
// emu_fatalerror is a generic fatal exception that provides an error string
|
||||||
|
class emu_fatalerror : public emu_exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
emu_fatalerror(const char *format, ...) ATTR_PRINTF(2,3);
|
||||||
|
emu_fatalerror(const char *format, va_list ap);
|
||||||
|
emu_fatalerror(int _exitcode, const char *format, ...) ATTR_PRINTF(3,4);
|
||||||
|
emu_fatalerror(int _exitcode, const char *format, va_list ap);
|
||||||
|
|
||||||
|
const char *string() const { return text; }
|
||||||
|
int exitcode() const { return code; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
char text[1024];
|
||||||
|
int code;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// standard assertion macros
|
// standard assertion macros
|
||||||
#undef assert
|
#undef assert
|
||||||
#undef assert_always
|
#undef assert_always
|
||||||
|
|
||||||
#if defined(MAME_DEBUG_FAST)
|
#if defined(MAME_DEBUG_FAST)
|
||||||
#define assert(x) do { } while (0)
|
#define assert(x) do { } while (0)
|
||||||
#define assert_always(x, msg) do { } while (0)
|
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
|
||||||
#elif defined(MAME_DEBUG)
|
#elif defined(MAME_DEBUG)
|
||||||
#define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0)
|
#define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0)
|
||||||
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
|
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
|
||||||
@ -50,10 +76,10 @@
|
|||||||
#define assert(x) do { } while (0)
|
#define assert(x) do { } while (0)
|
||||||
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0)
|
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0)
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// core system includes
|
// core system includes
|
||||||
#include "osdcomm.h"
|
|
||||||
#include "astring.h"
|
#include "astring.h"
|
||||||
#include "emualloc.h"
|
#include "emualloc.h"
|
||||||
#include "corestr.h"
|
#include "corestr.h"
|
||||||
@ -283,33 +309,6 @@ inline void operator--(_Type &value, int) { value = (_Type)((int)value - 1); }
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
|
||||||
// EXCEPTION CLASSES
|
|
||||||
//**************************************************************************
|
|
||||||
|
|
||||||
// emu_exception is the base class for all emu-related exceptions
|
|
||||||
class emu_exception : public std::exception { };
|
|
||||||
|
|
||||||
|
|
||||||
// emu_fatalerror is a generic fatal exception that provides an error string
|
|
||||||
class emu_fatalerror : public emu_exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
emu_fatalerror(const char *format, ...) ATTR_PRINTF(2,3);
|
|
||||||
emu_fatalerror(const char *format, va_list ap);
|
|
||||||
emu_fatalerror(int _exitcode, const char *format, ...) ATTR_PRINTF(3,4);
|
|
||||||
emu_fatalerror(int _exitcode, const char *format, va_list ap);
|
|
||||||
|
|
||||||
const char *string() const { return text; }
|
|
||||||
int exitcode() const { return code; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
char text[1024];
|
|
||||||
int code;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// CASTING TEMPLATES
|
// CASTING TEMPLATES
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user