From fd733201b82f39655488a286c89142f321ef9dc9 Mon Sep 17 00:00:00 2001 From: Sylvain Chiron Date: Sat, 1 Jul 2017 13:36:41 +0200 Subject: Updated libs from the Adaptagrams project: libavoid, libcola and libvspc; changed the code to match the new API Signed-off-by: Sylvain Chiron --- src/libavoid/debug.h | 70 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'src/libavoid/debug.h') diff --git a/src/libavoid/debug.h b/src/libavoid/debug.h index 443529ece..5f73dcf16 100644 --- a/src/libavoid/debug.h +++ b/src/libavoid/debug.h @@ -19,7 +19,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * Author(s): Michael Wybrow + * Author(s): Michael Wybrow */ @@ -27,31 +27,73 @@ #define AVOID_DEBUG_H -#ifdef LIBAVOID_DEBUG +#if defined(_MSC_VER) && defined(USE_ATLTRACE) + // Using Microsoft Visual C++ compiler and we want to use ATLTRACE + // to send warnings and error messages to a GUI window. -#include -#include + // Prevent inclusion of min and max macros. + #define NOMINMAX + #include #endif +#include +#include +#include + + namespace Avoid { +// db_printf is debugging output for verifying behaviour of the router: #ifdef LIBAVOID_DEBUG -inline void db_printf(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); -} + + #if defined(_MSC_VER) && defined(USE_ATLTRACE) + #define db_printf ATL::AtlTrace + #else + inline void db_printf(const char *fmt, ...) + { + va_list ap; + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + } + #endif + #else -inline void db_printf(const char *, ...) -{ -} + + inline void db_printf(const char *, ...) + { + } + +#endif + +// err_printf are critical errors that mean something pretty bad has happened: +#if defined(_MSC_VER) && defined(USE_ATLTRACE) + + #define err_printf ATL::AtlTrace + +#else + + // For other environments we always show these errors. + inline void err_printf(const char *fmt, ...) + { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + } + #endif } +// Precision of numbers in libavoid SVG debug file. Used in printf +// strings ("%" PREC "g"), e.g., "%.16g" +#if defined(HIGH_PRECISION_DEBUG) + #define PREC ".16" +#else + #define PREC "" +#endif #endif -- cgit v1.2.3