(svn r18057) -Codechange: replace assert_compile() by new one which works with gcc3.3 and removes the need of assert_tcompile()

This commit is contained in:
smatz 2009-11-13 15:53:51 +00:00
parent 1a04b9081a
commit 8d95e16ff1
2 changed files with 4 additions and 10 deletions

View File

@ -85,7 +85,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
template <typename TC, typename TS> template <typename TC, typename TS>
static inline void GetAllCargoSuffixes(uint cb_offset, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargos, TS &suffixes) static inline void GetAllCargoSuffixes(uint cb_offset, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargos, TS &suffixes)
{ {
assert_tcompile(lengthof(cargos) <= lengthof(suffixes)); assert_compile(lengthof(cargos) <= lengthof(suffixes));
for (uint j = 0; j < lengthof(cargos); j++) { for (uint j = 0; j < lengthof(cargos); j++) {
if (cargos[j] != CT_INVALID) { if (cargos[j] != CT_INVALID) {
GetCargoSuffix(cb_offset + j, cst, ind, ind_type, indspec, suffixes[j], lastof(suffixes[j])); GetCargoSuffix(cb_offset + j, cst, ind, ind_type, indspec, suffixes[j], lastof(suffixes[j]));

View File

@ -118,7 +118,6 @@
#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)))
@ -129,7 +128,6 @@
#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__ */
@ -183,7 +181,6 @@
#endif #endif
#define GCC_PACK #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)
@ -302,14 +299,11 @@ typedef unsigned char byte;
#if defined(__STDCXX_VERSION__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(static_assert) #if defined(__STDCXX_VERSION__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(static_assert)
/* __STDCXX_VERSION__ is c++0x feature macro, __GXX_EXPERIMENTAL_CXX0X__ is used by gcc, __GXX_EXPERIMENTAL_CPP0X__ by icc */ /* __STDCXX_VERSION__ is c++0x feature macro, __GXX_EXPERIMENTAL_CXX0X__ is used by gcc, __GXX_EXPERIMENTAL_CPP0X__ by icc */
#define assert_compile(expr) static_assert(expr, #expr ) #define assert_compile(expr) static_assert(expr, #expr )
#define assert_tcompile(expr) assert_compile(expr) #elif defined(__OS2__)
#elif defined(__OS2__) || (defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4) /* Disabled for OS/2 */
/* Disabled for OS/2 or GCC < 3.4 (GCC < 3 isn't supported anymore) */
#define assert_compile(expr) #define assert_compile(expr)
#define assert_tcompile(expr) assert(expr)
#else #else
#define assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)] UNUSED #define assert_compile(expr) typedef int __ct_assert__[1 - 2 * !(expr)]
#define assert_tcompile(expr) assert(expr)
#endif #endif
/* Check if the types have the bitsizes like we are using them */ /* Check if the types have the bitsizes like we are using them */