Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
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
elm::trace
void trace(CString file, int line, CString fun)
Definition: debug.h:28
elm::elm_spy
T elm_spy(cstring comment, T value)
Definition: debug.h:34
value
elm::CString
Definition: CString.h:17
elm
Definition: adapter.h:26
elm::io::endl
const EOL endl
Definition: io_Output.cpp:880
elm::cerr
io::Output cerr
elm::io::Output::flush
void flush(void)
Definition: io_Output.cpp:298