diff options
author | frosch <frosch@openttd.org> | 2013-01-20 15:02:28 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-01-20 15:02:28 +0000 |
commit | f73e43818c567f1c9413181f0950701551c03920 (patch) | |
tree | 74d98cb0c9fc629f8203056c2c8ad6332d4c21a0 | |
parent | 9b7c8cf7a7cf8adda7b141c029cde3c1449dfcd0 (diff) | |
download | openttd-f73e43818c567f1c9413181f0950701551c03920.tar.xz |
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
-rw-r--r-- | src/stdafx.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/stdafx.h b/src/stdafx.h index c6a7335c3..b3359b74d 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -28,31 +28,54 @@ /* It seems that we need to include stdint.h before anything else * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC - * does not have stdint.h and apparently neither does MorphOS, so define - * INT64_MAX for them ourselves. */ -#if defined(__APPLE__) - /* Already done in osx_stdafx.h */ -#elif !defined(_MSC_VER) && !defined( __MORPHOS__) && !defined(_STDINT_H_) + * does not have stdint.h and apparently neither does MorphOS. + * For OSX the inclusion is already done in osx_stdafx.h. */ +#if !defined(__APPLE__) && !defined(_MSC_VER) && !defined(__MORPHOS__) #if defined(SUNOS) /* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything * stdint.h defines and we need. */ #include <inttypes.h> - # else + #else #define __STDC_LIMIT_MACROS #include <stdint.h> #endif -#else +#endif + +/* The conditions for these constants to be available are way too messy; so check them one by one */ +#if !defined(UINT64_MAX) #define UINT64_MAX (18446744073709551615ULL) +#endif +#if !defined(INT64_MAX) #define INT64_MAX (9223372036854775807LL) +#endif +#if !defined(INT64_MIN) #define INT64_MIN (-INT64_MAX - 1) +#endif +#if !defined(UINT32_MAX) #define UINT32_MAX (4294967295U) +#endif +#if !defined(INT32_MAX) #define INT32_MAX (2147483647) +#endif +#if !defined(INT32_MIN) #define INT32_MIN (-INT32_MAX - 1) +#endif +#if !defined(UINT16_MAX) #define UINT16_MAX (65535U) +#endif +#if !defined(INT16_MAX) #define INT16_MAX (32767) +#endif +#if !defined(INT16_MIN) #define INT16_MIN (-INT16_MAX - 1) +#endif +#if !defined(UINT8_MAX) #define UINT8_MAX (255) +#endif +#if !defined(INT8_MAX) #define INT8_MAX (127) +#endif +#if !defined(INT8_MIN) #define INT8_MIN (-INT8_MAX - 1) #endif |