From: Michal MalĂ˝ Date: Thu, 10 Jul 2014 23:13:08 +0000 (+0200) Subject: - Prepend function name to PR_DEBUG output X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=3154f37c86a9a2ab06fd08a2ced855ba4a63812c;p=libHPCS.git - Prepend function name to PR_DEBUG output - Provide fully flexible PR_DEBUGF --- 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