From 01f9ae0f0fecf35334135c9a1bb3aa9e85d2d124 Mon Sep 17 00:00:00 2001 From: Felix Salfelder Date: Sat, 27 Aug 2016 04:47:18 +0100 Subject: [PATCH] fallback to C style traces, unless __cplusplus --- include/io_trace.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/include/io_trace.h b/include/io_trace.h index a39adfb8..7d51affe 100644 --- a/include/io_trace.h +++ b/include/io_trace.h @@ -44,6 +44,8 @@ /*--------------------------------------------------------------------------*/ #ifdef DO_TRACE +#ifdef __cplusplus + #define trace_line() (std::cerr << "@@#\n@#@:" \ << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" ) #define trace0(s) ( std::cerr << "@#@" << (s) << "\n") @@ -102,6 +104,26 @@ << " " << #y << "=" << (y) \ << " " << #z << "=" << (z) \ << "\n" ) + +#else // no __cplusplus + +#define trace_line() (printf("@@#\n@#@:%s:%u:%s\n", \ + __FILE__, __LINE__, __func__)) +#define trace0(s) (printf("@#@%s\n", s)) +#define trace1(s,x) (printf("@#@%s %s=%g\n", s, #x, (double)(x))) +#define trace2(s,x,y) (printf("@#@%s %s=%g %s=%g\n",\ + s, #x, (double)(x), #y, (double)(y))) +#define trace3(s,x,y,z) (printf("@#@%s %s=%g %s=%g %s=%g\n",\ + s, #x, (double)(x), #y, (double)(y), #z, (double)(z))) +#define trace4(s,w,x,y,z)(printf("@#@%s %s=%g %s=%g %s=%g %s=%g\n",\ + s, #w, (double)(w), #x, (double)(x), #y, (double)(y), #z, (double)(z))) +#define trace5(s,v,w,x,y,z)\ + (printf("@#@%s %s=%g %s=%g %s=%g %s=%g %s=%g\n",\ + s, #v, (double)(v), #w, (double)(w), #x, (double)(x),\ + #y, (double)(y), #z, (double)(z))) + +#endif // __cplusplus + #else #define USE(x) (1)?(void)(0):(void)(x) #define trace_line() @@ -116,6 +138,8 @@ #define trace8(r,s,t,u,v,w,x,y,z) USE(r);USE(s);USE(t);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z) #endif +#ifdef __cplusplus + #define unreachable() ( \ std::cerr << "@@#\n@@@\nunreachable:" \ << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" ) @@ -124,7 +148,20 @@ std::cerr << "@@#\n@@@\nincomplete:" \ << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" ) +#else // no __cplusplus + +#define unreachable() (fprintf(stderr,"@@#\n@@@unreachable:%s:%u:%s\n", \ + __FILE__, __LINE__, __func__)) + +#define incomplete() (fprintf(stderr,"@@#\n@@@incomplete:%s:%u:%s\n", \ + __FILE__, __LINE__, __func__)) + +#endif // __cplusplus + #ifdef TRACE_UNTESTED + +#ifdef __cplusplus + #define untested() ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \ <<":" << __func__ << "\n" ) #define untested1(s,x) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \ @@ -136,6 +173,14 @@ <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << ", "\ << #y << "=" << (y) << ", " \ << #z << "=" << (z) << "\n" ) + +#else // no __cplusplus + +#define untested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \ + __FILE__, __LINE__, __func__)) + +#endif // __cplusplus + #else #define untested() #define untested1(s,x) @@ -143,9 +188,18 @@ #define untested3(s,x,y,z) #endif +#ifdef __cplusplus + #ifdef TRACE_ITESTED #define itested() ( std::cerr << "@@#\n@@@:" \ << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" ) + +#else // no __cplusplus + +#define itested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \ + __FILE__, __LINE__, __func__)) +#endif // __cplusplus + #else #define itested() #endif -- 2.11.4.GIT