]> www.ginac.de Git - ginac.git/blob - ginac/polynomial/debug.h
48659fdd8bc4d3d2e086d6ec1d12f3a8a32f091d
[ginac.git] / ginac / polynomial / debug.h
1 #ifndef GINAC_MOD_GCD_DEBUG_HPP
2 #define GINAC_MOD_GCD_DEBUG_HPP
3 #include <iostream>
4 #include <string>
5 #include <stdexcept>
6 #include <sstream>
7 #include "compiler.h"
8
9 #define DEBUG_PREFIX __func__ << ':' << __LINE__ << ": "
10 #define EXCEPTION_PREFIX std::string(__func__) + std::string(": ") +
11
12 #define Dout2(stream, msg) \
13 do {                                                                    \
14         stream << DEBUG_PREFIX << msg << std::endl << std::flush;       \
15 } while (0)
16 #define Dout(msg) Dout2(std::cout, msg)
17
18 #define bug3_on(condition, the_exception, msg)                          \
19 do {                                                                    \
20         if (unlikely(condition)) {                                      \
21                 std::ostringstream err_stream;                          \
22                 Dout2(err_stream, "BUG: " << msg);                      \
23                 throw the_exception(err_stream.str());                  \
24         }                                                               \
25 } while (0)
26
27 #define bug_on(condition, msg) bug3_on(condition, std::logic_error, msg)
28
29 #endif // GINAC_MOD_GCD_DEBUG_HPP
30