diff --git a/src/Makefile.am b/src/Makefile.am index 6e7189351..fb4c485f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ COMMON_SOURCES = \ filter.c \ flexdef.h \ flexint.h \ + flexint_shared.h \ gen.c \ main.c \ misc.c \ @@ -95,7 +96,7 @@ CLEANFILES = stage1scan.c stage1flex$(EXEEXT) MAINTAINERCLEANFILES = skel.c -skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c +skel.c: flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c $(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp mv $@.tmp $@ diff --git a/src/flex.skl b/src/flex.skl index 67eea3c9d..1043238cf 100644 --- a/src/flex.skl +++ b/src/flex.skl @@ -248,10 +248,6 @@ m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]], , %endif /* end standard C headers. */ -%if-c-or-c++ -m4preproc_include(`flexint.h') -%endif - /* begin standard C++ headers. */ %if-c++-only #include @@ -262,6 +258,10 @@ m4preproc_include(`flexint.h') /* end standard C++ headers. */ %endif +%if-c-or-c++ +m4preproc_include(`flexint_shared.h') +%endif + /* TODO: this is always defined, so inline it */ #define yyconst const diff --git a/src/flexint.h b/src/flexint.h index 4b9e691ff..3576eaa64 100644 --- a/src/flexint.h +++ b/src/flexint.h @@ -3,10 +3,6 @@ #ifndef FLEXINT_H #define FLEXINT_H -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* C++ systems might need __STDC_LIMIT_MACROS defined before including * , if you want the limit (max/min) macros for int types. */ @@ -14,20 +10,10 @@ #define __STDC_LIMIT_MACROS 1 #endif -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; +/* "flexint_shared.h" will be included also in skeleton. It will include + * (if available) and define flex's integral types. + */ +#include "flexint_shared.h" /* Limits of integral types. */ #ifndef INT8_MIN @@ -65,6 +51,4 @@ typedef unsigned int flex_uint32_t; #define SIZE_MAX (~(size_t)0) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ diff --git a/src/flexint_shared.h b/src/flexint_shared.h new file mode 100644 index 000000000..569f0730b --- /dev/null +++ b/src/flexint_shared.h @@ -0,0 +1,22 @@ +/* flex integer type definitions */ + +/* Prefer C99 integer types if available. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +/* Include and not because Solaris 2.6 has the former + * and not the latter. + */ +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */