mirror of https://github.com/OpenTTD/OpenTTD
(svn r16715) -Codechange: add attribute to assert_compile(), so it doesn't warn when used inside function
parent
76a50ce94d
commit
93c5300fc5
|
@ -116,12 +116,10 @@ static FORCEINLINE T Align(const T x, uint n)
|
||||||
* @return The smallest multiple of n equal or greater than x
|
* @return The smallest multiple of n equal or greater than x
|
||||||
* @see Align()
|
* @see Align()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
assert_compile(sizeof(size_t) == sizeof(void *));
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static FORCEINLINE T *AlignPtr(T *x, uint n)
|
static FORCEINLINE T *AlignPtr(T *x, uint n)
|
||||||
{
|
{
|
||||||
|
assert_compile(sizeof(size_t) == sizeof(void *));
|
||||||
return (T *)Align((size_t)x, n);
|
return (T *)Align((size_t)x, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,9 +237,9 @@ static inline bool CheckOldSavegameType(FILE *f, char *temp, const char *last, u
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_compile(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
|
|
||||||
static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *last)
|
static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *last)
|
||||||
{
|
{
|
||||||
|
assert_compile(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
|
||||||
char temp[TTD_HEADER_SIZE];
|
char temp[TTD_HEADER_SIZE];
|
||||||
|
|
||||||
SavegameType type = SGT_TTO;
|
SavegameType type = SGT_TTO;
|
||||||
|
|
|
@ -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
|
* @param rt SLRefType type of the object the pointer is sought of
|
||||||
* @return Return the index converted to a pointer of any type
|
* @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)
|
static void *IntToReference(size_t index, SLRefType rt)
|
||||||
{
|
{
|
||||||
|
assert_compile(sizeof(size_t) <= sizeof(void *));
|
||||||
|
|
||||||
assert(_sl.action == SLA_PTRS);
|
assert(_sl.action == SLA_PTRS);
|
||||||
|
|
||||||
/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,
|
/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,
|
||||||
|
|
10
src/stdafx.h
10
src/stdafx.h
|
@ -123,6 +123,7 @@
|
||||||
#define CDECL
|
#define CDECL
|
||||||
#define __int64 long long
|
#define __int64 long long
|
||||||
#define GCC_PACK __attribute__((packed))
|
#define GCC_PACK __attribute__((packed))
|
||||||
|
#define UNUSED __attribute__((unused))
|
||||||
/* Warn about functions using 'printf' format syntax. First argument determines which parameter
|
/* 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. */
|
* is the format string, second argument is start of values passed to printf. */
|
||||||
#define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
|
#define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
|
||||||
|
@ -133,6 +134,7 @@
|
||||||
#define FORCEINLINE inline
|
#define FORCEINLINE inline
|
||||||
#define CDECL
|
#define CDECL
|
||||||
#define GCC_PACK
|
#define GCC_PACK
|
||||||
|
#define UNUSED
|
||||||
#define WARN_FORMAT(string, args)
|
#define WARN_FORMAT(string, args)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif /* __WATCOMC__ */
|
#endif /* __WATCOMC__ */
|
||||||
|
@ -184,6 +186,9 @@
|
||||||
#define CDECL _cdecl
|
#define CDECL _cdecl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GCC_PACK
|
||||||
|
#define UNUSED
|
||||||
|
|
||||||
int CDECL snprintf(char *str, size_t size, const char *format, ...) WARN_FORMAT(3, 4);
|
int CDECL snprintf(char *str, size_t size, const char *format, ...) WARN_FORMAT(3, 4);
|
||||||
#if defined(WINCE)
|
#if defined(WINCE)
|
||||||
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
||||||
|
@ -202,9 +207,6 @@
|
||||||
#define fseek _fseeki64
|
#define fseek _fseeki64
|
||||||
#endif /* _WIN64 || WIN64 */
|
#endif /* _WIN64 || WIN64 */
|
||||||
|
|
||||||
|
|
||||||
#define GCC_PACK
|
|
||||||
|
|
||||||
/* This is needed to zlib uses the stdcall calling convention on visual studio */
|
/* This is needed to zlib uses the stdcall calling convention on visual studio */
|
||||||
#if defined(WITH_ZLIB) || defined(WITH_PNG)
|
#if defined(WITH_ZLIB) || defined(WITH_PNG)
|
||||||
#if !defined(ZLIB_WINAPI)
|
#if !defined(ZLIB_WINAPI)
|
||||||
|
@ -304,7 +306,7 @@ typedef unsigned char byte;
|
||||||
#if defined(__OS2__)
|
#if defined(__OS2__)
|
||||||
#define assert_compile(expr)
|
#define assert_compile(expr)
|
||||||
#else
|
#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__ */
|
#endif /* __OS2__ */
|
||||||
|
|
||||||
/* Check if the types have the bitsizes like we are using them */
|
/* Check if the types have the bitsizes like we are using them */
|
||||||
|
|
Loading…
Reference in New Issue