summaryrefslogtreecommitdiffstats
path: root/src/libavoid/debug.h
diff options
context:
space:
mode:
authorSylvain Chiron <chironsylvain@orange.fr>2017-07-01 11:36:41 +0000
committerSylvain Chiron <chironsylvain@orange.fr>2017-07-01 11:36:41 +0000
commitfd733201b82f39655488a286c89142f321ef9dc9 (patch)
treea12c70f213414f69467f666619b1552103f6370e /src/libavoid/debug.h
parentHackfest icon work: restore selected menu icons and make theming easier (diff)
downloadinkscape-fd733201b82f39655488a286c89142f321ef9dc9.tar.gz
inkscape-fd733201b82f39655488a286c89142f321ef9dc9.zip
Updated libs from the Adaptagrams project: libavoid, libcola and libvspc; changed the code to match the new API
Signed-off-by: Sylvain Chiron <chironsylvain@orange.fr>
Diffstat (limited to 'src/libavoid/debug.h')
-rw-r--r--src/libavoid/debug.h70
1 files changed, 56 insertions, 14 deletions
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 <mjwybrow@users.sourceforge.net>
+ * 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 <stdarg.h>
-#include <iostream>
+ // Prevent inclusion of min and max macros.
+ #define NOMINMAX
+ #include <afx.h>
#endif
+#include <cstdarg>
+#include <cstdio>
+#include <iostream>
+
+
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