diff --git a/ChangeLog b/ChangeLog index d14a378e73..592b2b01b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-18 Michael Natterer + + * app/gimp-log.[ch]: changed to work with different + compiler-specific ways of doing macro varargs also cope with no + macro vararg support at all. Pointed out by Hans Breuer. + 2007-11-18 Michael Natterer * app/display/gimpdisplayshell-callbacks.c diff --git a/app/gimp-log.c b/app/gimp-log.c index 3e8f8c7e20..da2d7f6ca3 100644 --- a/app/gimp-log.c +++ b/app/gimp-log.c @@ -52,21 +52,27 @@ gimp_log (const gchar *function, const gchar *domain, const gchar *format, ...) +{ + va_list args; + + va_start (args, format); + gimp_logv (function, line, domain, format, args); + va_end (args); +} + +void +gimp_logv (const gchar *function, + gint line, + const gchar *domain, + const gchar *format, + va_list args) { gchar *message; if (format) - { - va_list args; - - va_start (args, format); - message = g_strdup_vprintf (format, args); - va_end (args); - } + message = g_strdup_vprintf (format, args); else - { - message = g_strdup ("called"); - } + message = g_strdup ("called"); g_log (domain, G_LOG_LEVEL_DEBUG, "%s(%d): %s", function, line, message); diff --git a/app/gimp-log.h b/app/gimp-log.h index c15abdf5e3..25cfa6cf52 100644 --- a/app/gimp-log.h +++ b/app/gimp-log.h @@ -28,12 +28,39 @@ typedef enum } GimpLogFlags; +#ifdef G_HAVE_ISO_VARARGS + +#define GIMP_LOG(type, ...) \ + G_STMT_START { \ + if (gimp_log_flags & GIMP_LOG_##type) \ + gimp_log (G_STRFUNC, __LINE__, #type, __VA_ARGS__); \ + } G_STMT_END + +#elif defined(G_HAVE_GNUC_VARARGS) + #define GIMP_LOG(type, format...) \ G_STMT_START { \ if (gimp_log_flags & GIMP_LOG_##type) \ gimp_log (G_STRFUNC, __LINE__, #type, format); \ } G_STMT_END +#else /* no varargs macros */ + +static void +GIMP_LOG (const gchar *function, + gint line, + const gchar *domain, + const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + gimp_logv (function, line, domain, format, args); + va_end (args); +} + +#endif /* !__GNUC__ */ + extern GimpLogFlags gimp_log_flags; @@ -44,6 +71,11 @@ void gimp_log (const gchar *function, const gchar *domain, const gchar *format, ...) G_GNUC_PRINTF (4, 5); +void gimp_logv (const gchar *function, + gint line, + const gchar *domain, + const gchar *format, + va_list args); #endif /* __GIMP_LOG_H__ */