summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorDavid Champion <dgc@extrahop.com>2020-11-20 09:33:41 -0800
committerKevin McCarthy <kevin@8t8.us>2020-11-23 19:43:47 -0800
commita3011236cac646d65fe84a4f79ea725b7004b530 (patch)
tree6c5f96e08d14a19e4a14c1cd858742f9f40f9200 /lib.h
parent49545f61738e545f0b80e399b687c65b705ae7cc (diff)
add dprintf(n, fmt, ...) debugging macro
dprintf(n, fmt, ...) is a more natural form of dprint(n, (debugfile, fmt, ...)). It prints code location in the debug file where possible. I believe this approach, while common, was not previously used because we were trying to be C90-compatible. C90 doesn't provide variadic macros. Now we require C99, so it makes sense to add this pattern.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index 92829252..1e98692d 100644
--- a/lib.h
+++ b/lib.h
@@ -149,12 +149,17 @@ MUTT_LIB_WHERE FILE *debugfile;
MUTT_LIB_WHERE int debuglevel;
void mutt_debug (FILE *, const char *, ...);
+void mutt_debug_f (const char *, const int, const char *, const char *, ...);
# define dprint(N,X) do { if (debuglevel>=N && debugfile) mutt_debug X; } while (0)
+/* __func__ is a C99 provision, but we now require C99 so it's safe */
+# define dprintf(N, ...) do { if (debuglevel >= (N)) mutt_debug_f (__FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
+
# else
# define dprint(N,X) do { } while (0)
+# define dprintf(N, ...) do { } while (0)
# endif