From: Ulya Trofimovich Date: Sun, 16 Aug 2015 19:02:04 +0000 (+0100) Subject: Force definition of some conditionally defined parts of . X-Git-Tag: 0.15~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f6a3f0282efde2f9b62eec181816c6c6ff03566;p=re2c Force definition of some conditionally defined parts of . Got some errors about undefined 'UINT32_MAX' and others while trying to build re2c with MINGW. These variables are defined conditionally in depending on the following defines: __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS Fix: defined these symbols in the beginning of "src/util/c99_stdint.h". Also found out that "src/util/c99_stdint.h" didn't compile in the absense of system (which is exactly the case when it was written for). THe problem was caused by incorrect use of 'typedef' statement; fixed easily. What a shame I didn't compile it before ;D --- diff --git a/re2c/src/util/c99_stdint.h b/re2c/src/util/c99_stdint.h index 772ffd51..7382eb50 100644 --- a/re2c/src/util/c99_stdint.h +++ b/re2c/src/util/c99_stdint.h @@ -3,6 +3,10 @@ #include "config.h" +// these defines enable some parts of +#define __STDC_LIMIT_MACROS // C99-7.18.2.1 Limits of exact-width integer types +#define __STDC_CONSTANT_MACROS // C99-7.18.4.1 Macros for minimum-width integer constants + #if HAVE_STDINT_H # include #else // HAVE_STDINT_H @@ -22,9 +26,8 @@ // (we consider even insane possibilities for simplicity). // The size of each type is defined by autoconf in the form // of a macro SIZEOF_ (set to 0 for nonexistent types). -// If we don't find a type with the required width, we typedef -// the corresponding exact-width C99 type to a nonexistent -// type name so that further compilation will fail. +// If we don't find a type with the required width, we don't +// define the corresponding exact-width C99 type at all. // // We define other types and constants based on exact-width // types and C99 standard. @@ -34,87 +37,91 @@ // We use SIZEOF_0 to find suitable 64-bit integer // constant suffix. -typedef +// C99-7.18.1.1 Exact-width integer types + +// int8_t, uint8_t #if SIZEOF_CHAR == 1 - char + typedef signed char int8_t; + typedef unsigned char uint8_t; #elif SIZEOF_SHORT == 1 - short + typedef signed short int8_t; + typedef unsigned short uint8_t; #elif SIZEOF_INT == 1 - int + typedef signed int int8_t; + typedef unsigned int uint8_t; #elif SIZEOF_LONG == 1 - long + typedef signed long int8_t; + typedef unsigned long uint8_t; #elif SIZEOF_LONG_LONG == 1 - long long + typedef signed long long int8_t; + typedef unsigned long long uint8_t; #elif SIZEOF___INT64 == 1 - __int64 -#else - nonexistent_byte1_type + typedef signed __int64 int8_t; + typedef unsigned __int64 uint8_t; #endif -byte1_type; -typedef +// int16_t, uint16_t #if SIZEOF_CHAR == 2 - char + typedef signed char int16_t; + typedef unsigned char uint16_t; #elif SIZEOF_SHORT == 2 - short + typedef signed short int16_t; + typedef unsigned short uint16_t; #elif SIZEOF_INT == 2 - int + typedef signed int int16_t; + typedef unsigned int uint16_t; #elif SIZEOF_LONG == 2 - long + typedef signed long int16_t; + typedef unsigned long uint16_t; #elif SIZEOF_LONG_LONG == 2 - long long + typedef signed long long int16_t; + typedef unsigned long long uint16_t; #elif SIZEOF___INT64 == 2 - __int64 -#else - nonexistent_byte2_type + typedef signed __int64 int16_t; + typedef unsigned __int64 uint16_t; #endif -byte2_type; -typedef +// int32_t, uint32_t #if SIZEOF_CHAR == 4 - char + typedef signed char int32_t; + typedef unsigned char uint32_t; #elif SIZEOF_SHORT == 4 - short + typedef signed short int32_t; + typedef unsigned short uint32_t; #elif SIZEOF_INT == 4 - int + typedef signed int int32_t; + typedef unsigned int uint32_t; #elif SIZEOF_LONG == 4 - long + typedef signed long int32_t; + typedef unsigned long uint32_t; #elif SIZEOF_LONG_LONG == 4 - long long + typedef signed long long int32_t; + typedef unsigned long long uint32_t; #elif SIZEOF___INT64 == 4 - __int64 -#else - nonexistent_byte4_type + typedef signed __int64 int32_t; + typedef unsigned __int64 uint32_t; #endif -byte4_type; -typedef +// int64_t, uint64_t #if SIZEOF_CHAR == 8 - char + typedef signed char int64_t; + typedef unsigned char uint64_t; #elif SIZEOF_SHORT == 8 - short + typedef signed short int64_t; + typedef unsigned short uint64_t; #elif SIZEOF_INT == 8 - int + typedef signed int int64_t; + typedef unsigned int uint64_t; #elif SIZEOF_LONG == 8 - long + typedef signed long int64_t; + typedef unsigned long uint64_t; #elif SIZEOF_LONG_LONG == 8 - long long + typedef signed long long int64_t; + typedef unsigned long long uint64_t; #elif SIZEOF___INT64 == 8 - __int64 -#else - nonexistent_byte8_type + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; #endif -byte8_type; - -// C99-7.18.1.1 Exact-width integer types -typedef byte1_type int8_t; -typedef byte2_type int16_t; -typedef byte4_type int32_t; -typedef byte8_type int64_t; -typedef unsigned byte1_type uint8_t; -typedef unsigned byte2_type uint16_t; -typedef unsigned byte4_type uint32_t; -typedef unsigned byte8_type uint64_t; // C99-7.18.1.2 Minimum-width integer types typedef int8_t int_least8_t;