diff --git a/Makefile.am b/Makefile.am index 73751f5b..13afec8b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -100,7 +100,7 @@ espeak_ng_include_HEADERS = \ lib_LTLIBRARIES += src/libespeak-ng.la src_libespeak_ng_la_LDFLAGS = -version-info $(SHARED_VERSION) -lpthread -lm -src_libespeak_ng_la_CFLAGS = -Isrc/include \ +src_libespeak_ng_la_CFLAGS = -Isrc/include -Isrc/include/compat \ -fPIC -fvisibility=hidden -D _BSD_SOURCE -D_DEFAULT_SOURCE -D _POSIX_C_SOURCE=200112L \ -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"$(DATADIR)\" src_libespeak_ng_la_SOURCES = \ diff --git a/src/include/compat/stdint.h b/src/include/compat/stdint.h new file mode 100644 index 00000000..d3b1622f --- /dev/null +++ b/src/include/compat/stdint.h @@ -0,0 +1,58 @@ +/* Compatibility shim for + * + * Copyright (C) 2016 Reece H. Dunn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see: . + */ + +#ifndef STDINT_H_COMPAT_SHIM +#define STDINT_H_COMPAT_SHIM + +#ifdef _MSC_VER + +#if _MSC_VER >= 1600 // Visual C++ 10 (Visual Studio 2010) and above... +#include <../include/stdint.h> +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef signed __int64 int64_t; + + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int64 uint64_t; + +#ifdef _WIN64 + typedef signed __int64 intptr_t; +#else + typedef signed __int32 intptr_t; +#endif +#endif + +#else + +#pragma GCC system_header // Silence "warning: #include_next is a GCC extension" + +#if defined(HAVE_STDINT_H) +#include_next +#elif defined(HAVE_INTTYPES_H) +#include_next +#else +#error stdint.h compatibility is not supported on this platform +#endif + +#endif + +#endif diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 1de8514e..09fb2a71 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index b2f40890..4374e398 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/compilembrola.c b/src/libespeak-ng/compilembrola.c index bac34120..0ced134c 100644 --- a/src/libespeak-ng/compilembrola.c +++ b/src/libespeak-ng/compilembrola.c @@ -23,9 +23,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 11f1770c..08c4ddbe 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -23,9 +23,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/error.c b/src/libespeak-ng/error.c index a51d6102..c9cd92f0 100644 --- a/src/libespeak-ng/error.c +++ b/src/libespeak-ng/error.c @@ -20,9 +20,7 @@ #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/espeak_api.c b/src/libespeak-ng/espeak_api.c index 50b3704b..b81fe25d 100644 --- a/src/libespeak-ng/espeak_api.c +++ b/src/libespeak-ng/espeak_api.c @@ -24,9 +24,7 @@ #include #include -#if HAVE_STDINT_H #include -#endif #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/intonation.c b/src/libespeak-ng/intonation.c index bb8b0305..438a851b 100644 --- a/src/libespeak-ng/intonation.c +++ b/src/libespeak-ng/intonation.c @@ -23,9 +23,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/klatt.c b/src/libespeak-ng/klatt.c index aff39ea1..2d305cdc 100644 --- a/src/libespeak-ng/klatt.c +++ b/src/libespeak-ng/klatt.c @@ -29,9 +29,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/numbers.c b/src/libespeak-ng/numbers.c index 57453001..b272a834 100644 --- a/src/libespeak-ng/numbers.c +++ b/src/libespeak-ng/numbers.c @@ -24,9 +24,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index 97d107b5..e7f42d60 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -22,9 +22,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 3db27204..7a79b237 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index 23774092..094e9396 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -23,9 +23,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/spect.c b/src/libespeak-ng/spect.c index 183e668c..47e5bde2 100644 --- a/src/libespeak-ng/spect.c +++ b/src/libespeak-ng/spect.c @@ -21,9 +21,7 @@ #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/speech.h b/src/libespeak-ng/speech.h index e6e1db5e..250fc792 100644 --- a/src/libespeak-ng/speech.h +++ b/src/libespeak-ng/speech.h @@ -61,14 +61,6 @@ typedef unsigned short USHORT; typedef unsigned char UCHAR; typedef double DOUBLEX; -#if !HAVE_STDINT_H -#ifdef _WIN64 -typedef signed __int64 intptr_t; -#else -typedef signed __int32 intptr_t; -#endif -#endif - typedef struct { const char *mnem; int value; diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 5d7d4c79..9ff54055 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index a4415a9a..d6114eb8 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 71418384..810aaf62 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -25,9 +25,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/tr_languages.c b/src/libespeak-ng/tr_languages.c index 318ba1f0..b702a7c7 100644 --- a/src/libespeak-ng/tr_languages.c +++ b/src/libespeak-ng/tr_languages.c @@ -25,9 +25,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index dbdd9a19..5ed23133 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -23,9 +23,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 32a08e6d..132117d4 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -24,9 +24,7 @@ #include "wctype.h" #include "string.h" #include "stdlib.h" -#if HAVE_STDINT_H #include -#endif #include "speech.h" diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index 80a4b968..243acdb4 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -26,9 +26,7 @@ #include #include #include -#if HAVE_STDINT_H #include -#endif #include #include diff --git a/src/windows/config.h b/src/windows/config.h index 0f99b868..d5453cd0 100644 --- a/src/windows/config.h +++ b/src/windows/config.h @@ -7,6 +7,3 @@ // reserved ISO C names (like strdup) in favour of non-portable conforming // variants that start with an '_'. This removes those deprecation warnings. #define _CRT_NONSTDC_NO_DEPRECATE - -// Visual C++ 2010 and later support . -#define HAVE_STDINT_H 1 \ No newline at end of file diff --git a/src/windows/libespeak-ng.vcxproj b/src/windows/libespeak-ng.vcxproj index c240d49c..42903141 100644 --- a/src/windows/libespeak-ng.vcxproj +++ b/src/windows/libespeak-ng.vcxproj @@ -87,7 +87,7 @@ Level3 Disabled - $(ProjectDir);$(ProjectDir)/../include + $(ProjectDir);$(ProjectDir)/../include;$(ProjectDir)/../include/compat _WINDLL;%(PreprocessorDefinitions) @@ -116,7 +116,7 @@ MaxSpeed true true - $(ProjectDir);$(ProjectDir)/../include + $(ProjectDir);$(ProjectDir)/../include;$(ProjectDir)/../include/compat _WINDLL;%(PreprocessorDefinitions) @@ -182,4 +182,4 @@ - \ No newline at end of file +