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 27, 2024
1 parent 032ccdc commit 701dcc8
Show file tree
Hide file tree
Showing 2 changed files with 12 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
14 changes: 11 additions & 3 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 701dcc8

Please sign in to comment.