Skip to content

Commit

Permalink
Log: Add __attribute__ to indicate that functions are like printf
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Mar 26, 2024
1 parent 032ccdc commit 830b8a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dbstring_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void RawStruct<std::vector<DBString>>::ReadLcf(std::vector<DBString>& ref, LcfRe
}

if (stream.Tell() != endpos) {
Log::Warning("vector<string> Misaligned at 0x" PRIx32 "", stream.Tell());
Log::Warning("vector<string> Misaligned at 0x%" PRIx32 "", stream.Tell());
stream.Seek(endpos);
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 830b8a8

Please sign in to comment.