(svn r16715) -Codechange: add attribute to assert_compile(), so it doesn't warn when used inside function

This commit is contained in:
smatz 2009-07-01 21:29:03 +00:00
parent 76a50ce94d
commit 93c5300fc5
4 changed files with 10 additions and 11 deletions

View File

@ -116,12 +116,10 @@ static FORCEINLINE T Align(const T x, uint n)
* @return The smallest multiple of n equal or greater than x
* @see Align()
*/
assert_compile(sizeof(size_t) == sizeof(void *));
template <typename T>
static FORCEINLINE T *AlignPtr(T *x, uint n)
{
assert_compile(sizeof(size_t) == sizeof(void *));
return (T *)Align((size_t)x, n);
}

View File

@ -237,9 +237,9 @@ static inline bool CheckOldSavegameType(FILE *f, char *temp, const char *last, u
return ret;
}
assert_compile(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *last)
{
assert_compile(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
char temp[TTD_HEADER_SIZE];
SavegameType type = SGT_TTO;

View File

@ -1498,11 +1498,10 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
* @param rt SLRefType type of the object the pointer is sought of
* @return Return the index converted to a pointer of any type
*/
assert_compile(sizeof(size_t) <= sizeof(void *));
static void *IntToReference(size_t index, SLRefType rt)
{
assert_compile(sizeof(size_t) <= sizeof(void *));
assert(_sl.action == SLA_PTRS);
/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,

View File

@ -123,6 +123,7 @@
#define CDECL
#define __int64 long long
#define GCC_PACK __attribute__((packed))
#define UNUSED __attribute__((unused))
/* Warn about functions using 'printf' format syntax. First argument determines which parameter
* is the format string, second argument is start of values passed to printf. */
#define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
@ -133,6 +134,7 @@
#define FORCEINLINE inline
#define CDECL
#define GCC_PACK
#define UNUSED
#define WARN_FORMAT(string, args)
#include <malloc.h>
#endif /* __WATCOMC__ */
@ -184,6 +186,9 @@
#define CDECL _cdecl
#endif
#define GCC_PACK
#define UNUSED
int CDECL snprintf(char *str, size_t size, const char *format, ...) WARN_FORMAT(3, 4);
#if defined(WINCE)
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
@ -202,9 +207,6 @@
#define fseek _fseeki64
#endif /* _WIN64 || WIN64 */
#define GCC_PACK
/* This is needed to zlib uses the stdcall calling convention on visual studio */
#if defined(WITH_ZLIB) || defined(WITH_PNG)
#if !defined(ZLIB_WINAPI)
@ -304,7 +306,7 @@ typedef unsigned char byte;
#if defined(__OS2__)
#define assert_compile(expr)
#else
#define assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)]
#define assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)] UNUSED
#endif /* __OS2__ */
/* Check if the types have the bitsizes like we are using them */