Activate PRINTF_VAARG_ATTRIBUTE for enable gcc to warn about some bad usage wih format.
This commit is contained in:
parent
d52a301924
commit
1ef5a6d8bc
5 changed files with 16 additions and 7 deletions
src
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue