From 830b8a8be3bbaf0167928295306b4c1d333a1c58 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 | 12 +++++++++--- 2 files changed, 10 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..613b0bc1 100644 --- a/src/log.h +++ b/src/log.h @@ -12,12 +12,18 @@ #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