diff debugmacros.h @ 0:76568becd6d6

Rhope Alpha 2a source import
author Mike Pavone <pavone@retrodev.com>
date Tue, 28 Apr 2009 23:06:07 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debugmacros.h	Tue Apr 28 23:06:07 2009 +0000
@@ -0,0 +1,72 @@
+#ifndef	_DEBUGMACROS_H_
+#define	_DEBUGMACROS_H_
+
+//#define TEXT_FILE_DEBUG	1
+
+#ifdef TEXT_FILE_DEBUG
+#include <stdio.h>
+
+void * debug_malloc(size_t size, char * msg);
+
+#define DEBUGPRINTF(format, ...)	fprintf(debugfile, format, __VA_ARGS__); fflush(debugfile)
+#define DEBUGPUTS(string)			fputs(string, debugfile); fflush(debugfile)
+
+extern FILE * debugfile;
+
+#ifdef MALLOC_DEBUG
+#define MALLOC(size, msg)			debug_malloc(size, msg)
+#define VIS_FREE(ptr, msg)				fprintf(debugfile, "free: %X, %s\n", ptr, msg); fflush(debugfile); free(ptr)
+#else
+#define MALLOC(size, msg)			malloc(size)
+#define VIS_FREE(ptr, msg)			free(ptr)
+#endif
+
+#else
+#ifdef	BOX_DEBUG
+
+#define DEBUGPRINTF(format, ...)	sprintf(debugbuffer, format, __VA_ARGS__); MessageBox(NULL, debugbuffer, "Debug", MB_OK)
+#define DEBUGPUTS(string)			MessageBox(NULL, string, "Debug", MB_OK)
+
+#else
+#ifdef CONSOLE_DEBUG
+#include <stdio.h>
+
+#define	DEBUGPRINTF(format, ...)	printf(format, __VA_ARGS__); fflush(stdout);
+#define	DEBUGPUTS(string)			fputs(string, stdout); fflush(stdout);
+
+#else
+
+#define	DEBUGPRINTF
+#define	DEBUGPUTS
+
+#define MALLOC(size, msg)			malloc(size)
+#define VIS_FREE(ptr, msg)				free(ptr)
+
+#endif	//CONSOLE_DEBUG
+#endif	//BOX_DEBUG
+#endif	//TEXT_FILE_DEBUG
+
+
+
+#ifdef WIN32
+	#ifdef GUI_LIB
+		extern char errorbuffer[1024];
+		#define ERRORPUTS(string)			DEBUGPUTS(string); MessageBox(NULL, string, "Rhope Error", MB_OK);
+		#define ERRORPRINTF(format, ...)	DEBUGPRINTF(format, __VA_ARGS__); sprintf(errorbuffer, format, __VA_ARGS__); MessageBox(NULL, errorbuffer, "Rhope Error", MB_OK);
+	#else
+		#define ERRORPUTS(string)	DEBUGPUTS(string); puts(string)/*fputs(string, stderr);*/
+		#define ERRORPRINTF(format, ...)	DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__);/* fprintf(stderr, format, __VA_ARGS__); */
+	#endif
+#else
+	#if defined(SEGA) | defined(NINTENDO_DS)
+		#define ERRORPUTS(string)	DEBUGPUTS(string); puts(string)
+		#define ERRORPRINTF(format, ...)	DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__)
+	#else
+		#define ERRORPUTS(string)	DEBUGPUTS(string); fputs(string, stderr)
+		#define ERRORPRINTF(format, ...)	DEBUGPRINTF(format, __VA_ARGS__); fprintf(stderr, format, __VA_ARGS__)
+	#endif
+#endif
+
+#endif //_DEBUGMACROS_H_
+
+