>From ff4eeda9266e27fc6e660aefa877de783c504da3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 17 Oct 2019 09:27:37 -0700 Subject: [PATCH 03/11] c: improve port of stdint.h usage to pre-C99 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oracle Solaris Studio 12.3 (Sun C 5.12 2011/11/16) by default does not conform to C99; it defines __STDC_VERSION__ to be 199409L, so the Bison code does not include (not required by C89 amendment 1) even though this compiler does have . On this platform defines INT_LEAST8_MAX (POSIX allows this) so the skeleton got confused and thought that had been included even though it wasn’t. * data/skeletons/c.m4 (b4_c99_int_type_define) [!__PTRDIFF_MAX__]: Always include . (YY_STDINT_H): Define when was included. All uses of expressions like ‘defined INT_LEAST8_MAX’ changed to ‘defined YY_STDINT_H’, since Sun C 5.12 defines macros like INT_LEAST8_MAX but does not declare types like int_least8_t. --- data/skeletons/c.m4 | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 586ee663..4580fd75 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -202,13 +202,10 @@ m4_define([b4_c99_int_type_define], so that the code can choose integer types of a good width. */ #ifndef __PTRDIFF_MAX__ -# ifndef INT_MAX -# include /* INFRINGES ON USER NAME SPACE */ -# endif -# ifndef PTRDIFF_MAX -# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# endif +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H # endif #endif @@ -219,7 +216,7 @@ m4_define([b4_c99_int_type_define], #ifdef __INT_LEAST8_MAX__ typedef __INT_LEAST8_TYPE__ yytype_int8; -#elif defined INT_LEAST8_MAX +#elif defined YY_STDINT_H typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; @@ -227,7 +224,7 @@ typedef signed char yytype_int8; #ifdef __INT_LEAST16_MAX__ typedef __INT_LEAST16_TYPE__ yytype_int16; -#elif defined INT_LEAST16_MAX +#elif defined YY_STDINT_H typedef int_least16_t yytype_int16; #else typedef short yytype_int16; @@ -235,7 +232,7 @@ typedef short yytype_int16; #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ typedef __UINT_LEAST8_TYPE__ yytype_uint8; -#elif (!defined __UINT_LEAST8_MAX__ && defined UINT_LEAST8_MAX \ +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ && UINT_LEAST8_MAX <= INT_MAX) typedef uint_least8_t yytype_uint8; #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX @@ -246,7 +243,7 @@ typedef short yytype_uint8; #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ typedef __UINT_LEAST16_TYPE__ yytype_uint16; -#elif (!defined __UINT_LEAST16_MAX__ && defined UINT_LEAST16_MAX \ +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ && UINT_LEAST16_MAX <= INT_MAX) typedef uint_least16_t yytype_uint16; #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX -- 2.21.0