From 3154f37c86a9a2ab06fd08a2ced855ba4a63812c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Fri, 11 Jul 2014 01:13:08 +0200 Subject: [PATCH] - Prepend function name to PR_DEBUG output - Provide fully flexible PR_DEBUGF --- libhpcs.c | 2 +- libhpcs_p.h | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libhpcs.c b/libhpcs.c index 92ca9d2..81510b2 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -527,7 +527,7 @@ static enum HPCS_ParseCode read_fixed_signal(FILE* datafile, struct HPCS_TVPair* read_file = false; break; default: - PR_DEBUG("Marker was expected but it was not found\n"); + PR_DEBUGF("%s %lu\n", "Marker was expected but it was not found at:", segments_read); free(*pairs); *pairs = NULL; return PARSE_E_NOT_FOUND; diff --git a/libhpcs_p.h b/libhpcs_p.h index eb4495a..a1fde65 100644 --- a/libhpcs_p.h +++ b/libhpcs_p.h @@ -123,7 +123,12 @@ void reverse_endianness(char* bytes, size_t sz) { #endif #ifndef NDEBUG -#define PR_DEBUG(msg) fprintf(stderr, msg) + #ifdef _MSC_VER + #define __func__ __FUNCTION__ + #endif + #define PR_DEBUGF(fmt, ...) fprintf(stderr, "[%s()] "fmt, __func__, __VA_ARGS__) + #define PR_DEBUG(msg) fprintf(stderr, "[%s()] "msg, __func__) #else -#define PR_DEBUG(msg) + #define PR_DEBUGF(fmt, msg) + #define PR_DEBUG(msg) #endif -- 2.43.5