comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:76568becd6d6
1 #ifndef _DEBUGMACROS_H_
2 #define _DEBUGMACROS_H_
3
4 //#define TEXT_FILE_DEBUG 1
5
6 #ifdef TEXT_FILE_DEBUG
7 #include <stdio.h>
8
9 void * debug_malloc(size_t size, char * msg);
10
11 #define DEBUGPRINTF(format, ...) fprintf(debugfile, format, __VA_ARGS__); fflush(debugfile)
12 #define DEBUGPUTS(string) fputs(string, debugfile); fflush(debugfile)
13
14 extern FILE * debugfile;
15
16 #ifdef MALLOC_DEBUG
17 #define MALLOC(size, msg) debug_malloc(size, msg)
18 #define VIS_FREE(ptr, msg) fprintf(debugfile, "free: %X, %s\n", ptr, msg); fflush(debugfile); free(ptr)
19 #else
20 #define MALLOC(size, msg) malloc(size)
21 #define VIS_FREE(ptr, msg) free(ptr)
22 #endif
23
24 #else
25 #ifdef BOX_DEBUG
26
27 #define DEBUGPRINTF(format, ...) sprintf(debugbuffer, format, __VA_ARGS__); MessageBox(NULL, debugbuffer, "Debug", MB_OK)
28 #define DEBUGPUTS(string) MessageBox(NULL, string, "Debug", MB_OK)
29
30 #else
31 #ifdef CONSOLE_DEBUG
32 #include <stdio.h>
33
34 #define DEBUGPRINTF(format, ...) printf(format, __VA_ARGS__); fflush(stdout);
35 #define DEBUGPUTS(string) fputs(string, stdout); fflush(stdout);
36
37 #else
38
39 #define DEBUGPRINTF
40 #define DEBUGPUTS
41
42 #define MALLOC(size, msg) malloc(size)
43 #define VIS_FREE(ptr, msg) free(ptr)
44
45 #endif //CONSOLE_DEBUG
46 #endif //BOX_DEBUG
47 #endif //TEXT_FILE_DEBUG
48
49
50
51 #ifdef WIN32
52 #ifdef GUI_LIB
53 extern char errorbuffer[1024];
54 #define ERRORPUTS(string) DEBUGPUTS(string); MessageBox(NULL, string, "Rhope Error", MB_OK);
55 #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); sprintf(errorbuffer, format, __VA_ARGS__); MessageBox(NULL, errorbuffer, "Rhope Error", MB_OK);
56 #else
57 #define ERRORPUTS(string) DEBUGPUTS(string); puts(string)/*fputs(string, stderr);*/
58 #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__);/* fprintf(stderr, format, __VA_ARGS__); */
59 #endif
60 #else
61 #if defined(SEGA) | defined(NINTENDO_DS)
62 #define ERRORPUTS(string) DEBUGPUTS(string); puts(string)
63 #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__)
64 #else
65 #define ERRORPUTS(string) DEBUGPUTS(string); fputs(string, stderr)
66 #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); fprintf(stderr, format, __VA_ARGS__)
67 #endif
68 #endif
69
70 #endif //_DEBUGMACROS_H_
71
72