summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/emucore.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2015-03-20 23:45:12 +1100
committer Vas Crabb <vas@vastheman.com>2015-03-20 23:45:12 +1100
commit5ffe5ce5513a51e7be74a0af90556bc2fa1aab5a (patch)
treef9b02320e3ee1fefc8f6e828b57bd3a19bfd4889 /src/emu/emucore.h
parentbff99e6130d303d667f2e16345c5fef6daa7c4da (diff)
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
Diffstat (limited to 'src/emu/emucore.h')
-rw-r--r--src/emu/emucore.h67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/emu/emucore.h b/src/emu/emucore.h
index 84bf56633f4..cb2de93caee 100644
--- a/src/emu/emucore.h
+++ b/src/emu/emucore.h
@@ -31,18 +31,44 @@
#include <exception>
#include <typeinfo>
-// TODO: make the assert replacement and especially assert_always work again
-#include <assert.h>
-#define assert_always(x, msg) assert(x)
+// needed for OSD macros
+#include "osdcomm.h"
+
+
+
+//**************************************************************************
+// 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
#undef assert
#undef assert_always
#if defined(MAME_DEBUG_FAST)
#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)
#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)
@@ -50,10 +76,10 @@
#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)
#endif
-*/
+
+
// core system includes
-#include "osdcomm.h"
#include "astring.h"
#include "emualloc.h"
#include "corestr.h"
@@ -284,33 +310,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
//**************************************************************************