]> www.ginac.de Git - ginac.git/blob - ginac/parser/debug.hpp
Faster, better (recursive descent) expression parser.
[ginac.git] / ginac / parser / debug.hpp
1 #ifndef GINAC_PARSER_DEBUG_HPP
2 #define GINAC_PARSER_DEBUG_HPP
3 #include <iosfwd>
4 #include <sstream>
5 #include <stdexcept>
6 #include "compiler.h"
7 #ifndef __GNUC__
8 #if __STDC_VERSION__ < 199901L
9 #define __PRETTY_FUNCTION__ "<unknown>"
10 #else
11 #define __PRETTY_FUNCTION__ __func__
12 #endif
13 #endif
14
15 #define bail_out(exception, message) \
16 do { \
17         std::ostringstream err; \
18         err << __PRETTY_FUNCTION__ << "(" << __FILE__ << ':' << __LINE__ << ": "; \
19         err << message; \
20         throw exception(err.str()); \
21 } while (0)
22
23 #define bug(message) bail_out(std::logic_error, message)
24
25 #define dout(condition, message) \
26 do { \
27         if (unlikely(condition)) { \
28                 std::cerr << __PRETTY_FUNCTION__ \
29                         << " (" << __FILE__ << ':' << __LINE__ << "): " \
30                         << message << std::endl; \
31         } \
32 } while (0)
33
34 #endif // GINAC_PARSER_DEBUG_HPP
35