Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
debug.h
1 /*
2  * $Id$
3  * Copyright (c) 2004-07, IRIT - UPS
4  *
5  * Debugging macros
6  */
7 #ifndef ELM_DEBUG_H
8 #define ELM_DEBUG_H
9 
10 #include <elm/io.h>
11 
12 namespace elm {
13 
14 // Debugging macros
15 #ifdef NDEBUG
16 # define TRACE
17 # define BREAK(cond)
18 # define HERE
19 # define SPY(c, v) (v)
20 #else
21 # define TRACE elm::trace(__FILE__, __LINE__, __PRETTY_FUNCTION__)
22 # define BREAK(cond) if(cond)
23 # define HERE { int x = 0; };
24 # define SPY(c, v) elm_spy(c, v)
25 #endif
26 
27 // Inlines
28 inline void trace(CString file, int line, CString fun) {
29  elm::cerr << "TRACE(" << file << ':' << line << ":" << fun << ")\n";
30  elm::cerr.flush();
31 }
32 
33 template <class T>
34 inline T elm_spy(cstring comment, T value) {
35  cerr << "DEBUG: " << comment << ": " << value << io::endl;
36  return value;
37 }
38 
39 } // elm
40 
41 #endif // ELM_DEBUG_H
Definition: CString.h:17
const char endl
Definition: Output.h:221
T elm_spy(cstring comment, T value)
Definition: debug.h:34
void trace(CString file, int line, CString fun)
Definition: debug.h:28
io::Output cerr
void flush(void)
Definition: io_Output.cpp:268
value_t value(CString name, int value)
Definition: rtti.h:40