Jim Cooper
/
simple_debug
Simple sample of using a debug class and macros.
debug.h@0:885c11431d59, 2015-08-30 (annotated)
- Committer:
- jimcooper
- Date:
- Sun Aug 30 00:05:14 2015 +0000
- Revision:
- 0:885c11431d59
Simple example of using a debug object and macros.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jimcooper | 0:885c11431d59 | 1 | #ifndef __DEBUG_H__ |
jimcooper | 0:885c11431d59 | 2 | #define __DEBUG_H__ |
jimcooper | 0:885c11431d59 | 3 | |
jimcooper | 0:885c11431d59 | 4 | |
jimcooper | 0:885c11431d59 | 5 | #ifndef DEBUG |
jimcooper | 0:885c11431d59 | 6 | #define DEBUG // Comment this out for release mode builds. |
jimcooper | 0:885c11431d59 | 7 | #endif |
jimcooper | 0:885c11431d59 | 8 | |
jimcooper | 0:885c11431d59 | 9 | |
jimcooper | 0:885c11431d59 | 10 | // Simple error reporting. |
jimcooper | 0:885c11431d59 | 11 | #ifdef DEBUG |
jimcooper | 0:885c11431d59 | 12 | #define DEBUG_ERROR(x) g_debugger.error(x); |
jimcooper | 0:885c11431d59 | 13 | #else |
jimcooper | 0:885c11431d59 | 14 | #define DEBUG_ERROR(x) // x; |
jimcooper | 0:885c11431d59 | 15 | #endif |
jimcooper | 0:885c11431d59 | 16 | |
jimcooper | 0:885c11431d59 | 17 | |
jimcooper | 0:885c11431d59 | 18 | |
jimcooper | 0:885c11431d59 | 19 | // debug error reporting object |
jimcooper | 0:885c11431d59 | 20 | class debug |
jimcooper | 0:885c11431d59 | 21 | { |
jimcooper | 0:885c11431d59 | 22 | public: |
jimcooper | 0:885c11431d59 | 23 | |
jimcooper | 0:885c11431d59 | 24 | void error(const char* text); |
jimcooper | 0:885c11431d59 | 25 | }; |
jimcooper | 0:885c11431d59 | 26 | |
jimcooper | 0:885c11431d59 | 27 | |
jimcooper | 0:885c11431d59 | 28 | // Created in the debug.cpp file. |
jimcooper | 0:885c11431d59 | 29 | extern debug g_debugger; |
jimcooper | 0:885c11431d59 | 30 | |
jimcooper | 0:885c11431d59 | 31 | |
jimcooper | 0:885c11431d59 | 32 | |
jimcooper | 0:885c11431d59 | 33 | #endif // __DEBUG_H__ |