From 701dcc8b045ebaa58a8b358278c16e3ab54197ed Mon Sep 17 00:00:00 2001 From: Ghabry Date: Tue, 26 Mar 2024 02:07:22 +0100 Subject: [PATCH] Log: Add __attribute__ to indicate that functions are like printf --- src/dbstring_struct.cpp | 2 +- src/log.h | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dbstring_struct.cpp b/src/dbstring_struct.cpp index 401df477..fbe5b8d3 100644 --- a/src/dbstring_struct.cpp +++ b/src/dbstring_struct.cpp @@ -107,7 +107,7 @@ void RawStruct>::ReadLcf(std::vector& ref, LcfRe } if (stream.Tell() != endpos) { - Log::Warning("vector Misaligned at 0x" PRIx32 "", stream.Tell()); + Log::Warning("vector Misaligned at 0x%" PRIx32 "", stream.Tell()); stream.Seek(endpos); } } diff --git a/src/log.h b/src/log.h index f489ca34..098e384f 100644 --- a/src/log.h +++ b/src/log.h @@ -12,14 +12,22 @@ #include "lcf/log_handler.h" +#ifdef __GNUG__ + #define LIKE_PRINTF __attribute__((format(printf, 1, 2))) +#else + #define LIKE_PRINTF +#endif + namespace lcf { namespace Log { -void Debug(const char* fmt, ...); -void Warning(const char* fmt, ...); -void Error(const char* fmt, ...); +void Debug(const char* fmt, ...) LIKE_PRINTF; +void Warning(const char* fmt, ...) LIKE_PRINTF; +void Error(const char* fmt, ...) LIKE_PRINTF; } // namespace Log } // namespace lcf +#undef LIKE_PRINTF + #endif