Assume that stdint.h is available on Windows with compilers other than MSVC <= 2008

This commit is contained in:
Cameron Cawley 2022-09-04 17:50:29 +01:00 committed by Sam Lantinga
parent ef988fe184
commit fd93f817ba
8 changed files with 52 additions and 201 deletions

View File

@ -930,6 +930,7 @@ endif()
if(SDL_LIBC) if(SDL_LIBC)
if(WINDOWS AND NOT MINGW) if(WINDOWS AND NOT MINGW)
set(HAVE_LIBC TRUE) set(HAVE_LIBC TRUE)
check_include_file(stdint.h HAVE_STDINT_H)
foreach(_HEADER stdio.h string.h wchar.h ctype.h math.h limits.h) foreach(_HEADER stdio.h string.h wchar.h ctype.h math.h limits.h)
string(TOUPPER "HAVE_${_HEADER}" _UPPER) string(TOUPPER "HAVE_${_HEADER}" _UPPER)
string(REPLACE "." "_" _HAVE_H ${_UPPER}) string(REPLACE "." "_" _HAVE_H ${_UPPER})
@ -1043,6 +1044,7 @@ else()
if(WINDOWS) if(WINDOWS)
set(HAVE_STDARG_H 1) set(HAVE_STDARG_H 1)
set(HAVE_STDDEF_H 1) set(HAVE_STDDEF_H 1)
check_include_file(stdint.h HAVE_STDINT_H)
endif() endif()
endif() endif()

View File

@ -206,14 +206,11 @@
#cmakedefine HAVE_POLL 1 #cmakedefine HAVE_POLL 1
#cmakedefine HAVE__EXIT 1 #cmakedefine HAVE__EXIT 1
#elif defined(__WIN32__) #else
#cmakedefine HAVE_STDARG_H 1 #cmakedefine HAVE_STDARG_H 1
#cmakedefine HAVE_STDDEF_H 1 #cmakedefine HAVE_STDDEF_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_FLOAT_H 1
#else
/* We may need some replacement for stdarg.h here */
#include <stdarg.h>
#endif /* HAVE_LIBC */ #endif /* HAVE_LIBC */
#cmakedefine HAVE_ALTIVEC_H 1 #cmakedefine HAVE_ALTIVEC_H 1
@ -533,24 +530,9 @@
#cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@ #cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@
#cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@ #cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@
#if !defined(__WIN32__) && !defined(__WINRT__) #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
typedef unsigned int size_t; #if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t;
# endif /* if (stdint.h isn't available) */
#else /* __WIN32__ */
# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__CODEGEARC__)
#define HAVE_STDINT_H 1
# elif defined(_MSC_VER)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t; typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t; typedef signed __int16 int16_t;
@ -559,37 +541,15 @@ typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t; typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t; typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t; typedef unsigned __int64 uint64_t;
# ifndef _UINTPTR_T_DEFINED #ifndef _UINTPTR_T_DEFINED
# ifdef _WIN64 #ifdef _WIN64
typedef unsigned __int64 uintptr_t; typedef unsigned __int64 uintptr_t;
# else #else
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
# endif #endif
#define _UINTPTR_T_DEFINED #define _UINTPTR_T_DEFINED
# endif #endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ #endif /* Visual Studio 2008 */
# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) #endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#define DWORD_PTR DWORD
# endif
# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
# endif
# else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
# ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
# endif
typedef unsigned int uintptr_t;
# endif /* __GNUC__ || _MSC_VER */
# endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#endif /* __WIN32__ */
#endif /* SDL_config_h_ */ #endif /* SDL_config_h_ */

View File

@ -34,23 +34,29 @@
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_MSC_VER) && (_MSC_VER < 1600)
/* Here are some reasonable defaults */ typedef signed __int8 int8_t;
typedef unsigned int size_t; typedef unsigned __int8 uint8_t;
typedef signed char int8_t; typedef signed __int16 int16_t;
typedef unsigned char uint8_t; typedef unsigned __int16 uint16_t;
typedef signed short int16_t; typedef signed __int32 int32_t;
typedef unsigned short uint16_t; typedef unsigned __int32 uint32_t;
typedef signed int int32_t; typedef signed __int64 int64_t;
typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t;
typedef signed long long int64_t; #ifndef _UINTPTR_T_DEFINED
typedef unsigned long long uint64_t; #ifdef _WIN64
typedef unsigned long uintptr_t; typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
#else #else
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#define HAVE_INTTYPES_H 1
#endif /* Visual Studio 2008 */ #endif /* Visual Studio 2008 */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef __GNUC__ #ifdef __GNUC__
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1

View File

@ -53,9 +53,8 @@
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__clang__) || defined(__BORLANDC__) || defined(__CODEGEARC__) /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#define HAVE_STDINT_H 1 #if defined(_MSC_VER) && (_MSC_VER < 1600)
#elif defined(_MSC_VER)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t; typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t; typedef signed __int16 int16_t;
@ -72,28 +71,9 @@ typedef unsigned int uintptr_t;
#endif #endif
#define _UINTPTR_T_DEFINED #define _UINTPTR_T_DEFINED
#endif #endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ #else
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) #define HAVE_STDINT_H 1
#define DWORD_PTR DWORD #endif /* Visual Studio 2008 */
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ #endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64 #ifdef _WIN64

View File

@ -28,40 +28,6 @@
/* Windows GDK does not need Windows SDK version checks because it requires /* Windows GDK does not need Windows SDK version checks because it requires
* a recent version of the Windows 10 SDK. */ * a recent version of the Windows 10 SDK. */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
/* At this time, only recent MSVC or clang are supported by Windows GDK */
#if defined(__clang__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
typedef unsigned __int64 uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
#else /* !__clang__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __clang__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
/* GDK only supports 64-bit */ /* GDK only supports 64-bit */
# define SIZEOF_VOIDP 8 # define SIZEOF_VOIDP 8
@ -101,6 +67,7 @@ typedef unsigned int uintptr_t;
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1 #define HAVE_STDIO_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
@ -197,6 +164,7 @@ typedef unsigned int uintptr_t;
#else #else
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#endif #endif
/* Enable various audio drivers */ /* Enable various audio drivers */

View File

@ -42,50 +42,6 @@
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64 #ifdef _WIN64
# define SIZEOF_VOIDP 8 # define SIZEOF_VOIDP 8
#else #else
@ -113,6 +69,7 @@ typedef unsigned int uintptr_t;
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1 #define HAVE_STDIO_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1

View File

@ -28,40 +28,6 @@
/* Windows GDK does not need Windows SDK version checks because it requires /* Windows GDK does not need Windows SDK version checks because it requires
* a recent version of the Windows 10 SDK. */ * a recent version of the Windows 10 SDK. */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
/* At this time, only recent MSVC or clang are supported by Windows GDK */
#if defined(__clang__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
typedef unsigned __int64 uintptr_t;
#define _UINTPTR_T_DEFINED
#endif
#else /* !__clang__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __clang__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
/* GDK only supports 64-bit */ /* GDK only supports 64-bit */
# define SIZEOF_VOIDP 8 # define SIZEOF_VOIDP 8
@ -101,6 +67,7 @@ typedef unsigned int uintptr_t;
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1 #define HAVE_STDIO_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
@ -197,6 +164,7 @@ typedef unsigned int uintptr_t;
#else #else
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#endif #endif
/* Enable various audio drivers */ /* Enable various audio drivers */

View File

@ -69,6 +69,16 @@
#include <windows.h> #include <windows.h>
#include <basetyps.h> /* for REFIID with broken mingw.org headers */ #include <basetyps.h> /* for REFIID with broken mingw.org headers */
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
#ifndef DWORD_PTR
#define DWORD_PTR DWORD
#endif
#ifndef LONG_PTR
#define LONG_PTR LONG
#endif
#endif
#include "SDL_rect.h" #include "SDL_rect.h"
/* Routines to convert from UTF8 to native Windows text */ /* Routines to convert from UTF8 to native Windows text */