X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fparser%2Fdebug.hpp;fp=ginac%2Fparser%2Fdebug.hpp;h=a43cc7ade4d86c4d9b05907d08083fcde2a04998;hp=0000000000000000000000000000000000000000;hb=1222eac51cee964961d2aad889dc4ceccb144a36;hpb=321d5c941f81b1d0b86de91f3f17c5af5b6e4642 diff --git a/ginac/parser/debug.hpp b/ginac/parser/debug.hpp new file mode 100644 index 00000000..a43cc7ad --- /dev/null +++ b/ginac/parser/debug.hpp @@ -0,0 +1,35 @@ +#ifndef GINAC_PARSER_DEBUG_HPP +#define GINAC_PARSER_DEBUG_HPP +#include +#include +#include +#include "compiler.h" +#ifndef __GNUC__ +#if __STDC_VERSION__ < 199901L +#define __PRETTY_FUNCTION__ "" +#else +#define __PRETTY_FUNCTION__ __func__ +#endif +#endif + +#define bail_out(exception, message) \ +do { \ + std::ostringstream err; \ + err << __PRETTY_FUNCTION__ << "(" << __FILE__ << ':' << __LINE__ << ": "; \ + err << message; \ + throw exception(err.str()); \ +} while (0) + +#define bug(message) bail_out(std::logic_error, message) + +#define dout(condition, message) \ +do { \ + if (unlikely(condition)) { \ + std::cerr << __PRETTY_FUNCTION__ \ + << " (" << __FILE__ << ':' << __LINE__ << "): " \ + << message << std::endl; \ + } \ +} while (0) + +#endif // GINAC_PARSER_DEBUG_HPP +