r18716 - gnucash/trunk/src/libqof/qof - Make libqof compatible for MSVC9.0 compiler (no joke).

Christian Stimming cstim at code.gnucash.org
Wed Feb 24 12:38:35 EST 2010


Author: cstim
Date: 2010-02-24 12:38:35 -0500 (Wed, 24 Feb 2010)
New Revision: 18716
Trac: http://svn.gnucash.org/trac/changeset/18716

Modified:
   gnucash/trunk/src/libqof/qof/gnc-numeric.c
   gnucash/trunk/src/libqof/qof/qoflog.h
Log:
Make libqof compatible for MSVC9.0 compiler (no joke).

The main change is that the syntax for variadic macros is
slightly different in MSVC compared to gcc. But they exist, so
offering the log macros in the different syntax is sufficient.

Modified: gnucash/trunk/src/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-numeric.c	2010-02-24 17:38:14 UTC (rev 18715)
+++ gnucash/trunk/src/libqof/qof/gnc-numeric.c	2010-02-24 17:38:35 UTC (rev 18716)
@@ -26,8 +26,8 @@
 
 #include <glib.h>
 #include <math.h>
-#ifdef G_OS_WIN32
-#include <pow.h>
+#if defined(G_OS_WIN32) && !defined(_MSC_VER)
+# include <pow.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>

Modified: gnucash/trunk/src/libqof/qof/qoflog.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qoflog.h	2010-02-24 17:38:14 UTC (rev 18715)
+++ gnucash/trunk/src/libqof/qof/qoflog.h	2010-02-24 17:38:35 UTC (rev 18716)
@@ -167,7 +167,62 @@
 
 #define PRETTY_FUNC_NAME qof_log_prettify(G_STRFUNC)
 
+#ifdef _MSC_VER
+/* Microsoft Visual Studio */
+
 /** Log a fatal error */
+#define FATAL(format, ...) do { \
+    g_log (log_module, G_LOG_LEVEL_FATAL, \
+      "[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
+} while (0)
+
+/** Log a serious error */
+#define PERR(format, ...) do { \
+    g_log (log_module, G_LOG_LEVEL_CRITICAL, \
+      "[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
+} while (0)
+
+/** Log a warning */
+#define PWARN(format, ...) do { \
+    g_log (log_module, G_LOG_LEVEL_WARNING, \
+      "[%s()] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
+} while (0)
+
+/** Print an informational note */
+#define PINFO(format, ...) do { \
+    g_log (log_module, G_LOG_LEVEL_INFO, \
+      "[%s] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
+} while (0)
+
+/** Print a debugging message */
+#define DEBUG(format, ...) do { \
+    g_log (log_module, G_LOG_LEVEL_DEBUG, \
+      "[%s] " format, PRETTY_FUNC_NAME , __VA_ARGS__); \
+} while (0)
+
+/** Print a function entry debugging message */
+#define ENTER(format, ...) do { \
+    if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
+      g_log (log_module, G_LOG_LEVEL_DEBUG, \
+        "[enter %s:%s()] " format, __FILE__, \
+        PRETTY_FUNC_NAME , __VA_ARGS__); \
+      qof_log_indent(); \
+    } \
+} while (0)
+
+/** Print a function exit debugging message. **/
+#define LEAVE(format, ...) do { \
+    if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
+      qof_log_dedent(); \
+      g_log (log_module, G_LOG_LEVEL_DEBUG, \
+        "[leave %s()] " format, \
+        PRETTY_FUNC_NAME , __VA_ARGS__); \
+    } \
+} while (0)
+
+#else /* _MSC_VER */
+
+/** Log a fatal error */
 #define FATAL(format, args...) do { \
     g_log (log_module, G_LOG_LEVEL_FATAL, \
       "[%s()] " format, PRETTY_FUNC_NAME , ## args); \
@@ -207,6 +262,18 @@
     } \
 } while (0)
 
+/** Print a function exit debugging message. **/
+#define LEAVE(format, args...) do { \
+    if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
+      qof_log_dedent(); \
+      g_log (log_module, G_LOG_LEVEL_DEBUG, \
+        "[leave %s()] " format, \
+        PRETTY_FUNC_NAME , ## args); \
+    } \
+} while (0)
+
+#endif /* _MSC_VER */
+
 /** Replacement for @c g_return_val_if_fail, but calls LEAVE if the test fails. **/
 #define gnc_leave_return_val_if_fail(test, val) do { \
   if (! (test)) { LEAVE(""); } \
@@ -219,16 +286,6 @@
   g_return_if_fail(test); \
 } while (0);
 
-/** Print a function exit debugging message. **/
-#define LEAVE(format, args...) do { \
-    if (qof_log_check(log_module, (QofLogLevel)G_LOG_LEVEL_DEBUG)) { \
-      qof_log_dedent(); \
-      g_log (log_module, G_LOG_LEVEL_DEBUG, \
-        "[leave %s()] " format, \
-        PRETTY_FUNC_NAME , ## args); \
-    } \
-} while (0)
-
 /* -------------------------------------------------------- */
 
 /** Infrastructure to make timing measurements for critical pieces
@@ -250,7 +307,34 @@
                              const gchar *function_name,
                              const gchar *format, ...);
 
+#ifdef _MSC_VER
+/* Microsoft Visual Studio */
+
 /** start a particular timer */
+#define START_CLOCK(clockno,format, ...) do {        \
+  if (qof_log_check (log_module, QOF_LOG_INFO))          \
+    qof_start_clock (clockno, log_module, QOF_LOG_INFO,  \
+             G_STRFUNC, format , __VA_ARGS__);               \
+} while (0)
+
+/** report elapsed time since last report on a particular timer */
+#define REPORT_CLOCK(clockno,format, ...) do {       \
+  if (qof_log_check (log_module, QOF_LOG_INFO))          \
+    qof_report_clock (clockno, log_module, QOF_LOG_INFO, \
+             G_STRFUNC, format , __VA_ARGS__);               \
+} while (0)
+
+/** report total elapsed time since timer started */
+#define REPORT_CLOCK_TOTAL(clockno,format, ...) do {       \
+  if (qof_log_check (log_module, QOF_LOG_INFO))                \
+    qof_report_clock_total (clockno, log_module, QOF_LOG_INFO, \
+             G_STRFUNC, format , __VA_ARGS__);               \
+} while (0)
+
+
+#else /* _MSC_VER */
+
+/** start a particular timer */
 #define START_CLOCK(clockno,format, args...) do {        \
   if (qof_log_check (log_module, QOF_LOG_INFO))          \
     qof_start_clock (clockno, log_module, QOF_LOG_INFO,  \
@@ -271,7 +355,9 @@
              G_STRFUNC, format , ## args);               \
 } while (0)
 
+#endif /* _MSC_VER */
 
+
 #endif /* _QOF_LOG_H */
 
 /** @} */



More information about the gnucash-changes mailing list