diff --git a/src/include/interface.h b/src/include/interface.h index 6c71ec7a7..9562cb1b3 100644 --- a/src/include/interface.h +++ b/src/include/interface.h @@ -349,9 +349,9 @@ extern void DrawMessages(); /// Draw the player resource in resource line extern void DrawResources(); /// Set message to display -extern void SetMessage(const char *fmt, ...); +extern void SetMessage(const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(1, 2); /// Set message to display with event point -extern void SetMessageEvent(int x, int y, const char *fmt, ...); +extern void SetMessageEvent(int x, int y, const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(3, 4); /// Center view-point on last event message extern void CenterOnMessage(); /// Cleanup all messages diff --git a/src/include/iolib.h b/src/include/iolib.h index cc8f732fa..52ea30f61 100644 --- a/src/include/iolib.h +++ b/src/include/iolib.h @@ -68,7 +68,7 @@ class FileWriter public: virtual ~FileWriter() {} - void printf(const char *format, ...); + void printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3); // Don't forget to count this virtual int write(const char *data, unsigned int size) = 0; }; @@ -113,7 +113,8 @@ public: int read(void *buf, size_t len); int seek(long offset, int whence); long tell(); - int printf(const char *format, ...); + + int printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3); // Don't forget to count this private: int cl_type; /// type of CFile diff --git a/src/include/player.h b/src/include/player.h index 77db44a6f..a2e2af119 100644 --- a/src/include/player.h +++ b/src/include/player.h @@ -402,7 +402,7 @@ public: int HaveUnitTypeByIdent(const std::string &ident) const; /// Notify player about a problem - void Notify(int type, int x, int y, const char *fmt, ...) const; + void Notify(int type, int x, int y, const char *fmt, ...) const PRINTF_VAARG_ATTRIBUTE(5, 6); // Don't forget to count this /** ** Check if the player index is an enemy diff --git a/src/include/stratagus.h b/src/include/stratagus.h index 5c1667c38..775e103fa 100644 --- a/src/include/stratagus.h +++ b/src/include/stratagus.h @@ -97,6 +97,14 @@ #define UNUSED(var) (var) #endif +#ifdef __GNUC__ +#define PRINTF_VAARG_ATTRIBUTE(a, b) __attribute__((format (printf, a, b))) +#else +#define PRINTF_VAARG_ATTRIBUTE(a, b) +#endif + + + /*============================================================================ == Debug definitions ============================================================================*/ @@ -276,7 +284,7 @@ extern void DrawMapArea(); /// Draw the map area extern void GameMainLoop(); /// Game main loop /// Show load progress -extern void ShowLoadProgress(const char *fmt, ...); +extern void ShowLoadProgress(const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(1, 2); struct DisplayAutoLocker { DisplayAutoLocker(); diff --git a/src/unit/unit_manager.cpp b/src/unit/unit_manager.cpp index 64be01d10..f070bd0af 100644 --- a/src/unit/unit_manager.cpp +++ b/src/unit/unit_manager.cpp @@ -126,7 +126,7 @@ void CUnitManager::Save(CFile *file) std::list<CUnit *>::iterator it = ReleasedUnits.begin(); for (; it != ReleasedUnits.end(); ++it) { - file->printf(", {Slot = %d, FreeCycle = %lu}", (*it)->Slot, (*it)->Refs); + file->printf(", {Slot = %d, FreeCycle = %u}", (*it)->Slot, (*it)->Refs); } file->printf(")\n"); }