changed to work with different compiler-specific ways of doing macro

2007-11-18  Michael Natterer  <mitch@gimp.org>

	* 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.


svn path=/trunk/; revision=24184
This commit is contained in:
Michael Natterer
2007-11-18 17:03:47 +00:00
committed by Michael Natterer
parent bcb2a4e942
commit f98e9de791
3 changed files with 54 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2007-11-18 Michael Natterer <mitch@gimp.org>
* 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 <mitch@gimp.org>
* app/display/gimpdisplayshell-callbacks.c

View File

@ -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);

View File

@ -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__ */