From a369f7c88ac33ee792046ed08eb2aa360befcea0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Feb 2004 12:58:08 +0000 Subject: [PATCH] Win64 compilation fixes: define SIZEOF_SIZE_T, added wxUIntPtr git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure.in | 1 + include/wx/defs.h | 49 ++++++++++++++++++++++++++++++++++------------- setup.h.in | 7 +++++-- setup.h_vms | 7 +++++-- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/configure.in b/configure.in index 560b267978..0d2097d839 100644 --- a/configure.in +++ b/configure.in @@ -1595,6 +1595,7 @@ AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(void *, 4) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(size_t, 4) case "${host}" in arm-*-linux* ) diff --git a/include/wx/defs.h b/include/wx/defs.h index f665c110b9..8231ab2b64 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -622,15 +622,6 @@ typedef wxUint16 wxWord; /* 32bit */ #ifdef __WINDOWS__ - #if defined(__WIN64__) - /* you may remove this #error and try to compile the library, please */ - /* report the results to wx-dev@lists.wxwindows.org if you do! */ - #error "wxWindows hasn't been tested under Win64, continue at your own risk" - - /* the same definitions as for Win32 _should_ work here as only */ - /* sizeof(void *) changes, but it must be tested first */ - #endif /* __WIN64__ */ - /* Win64 uses LLP64 model and so ints and longs have the same size as in */ /* Win32 */ #if defined(__WIN32__) @@ -643,13 +634,25 @@ typedef wxUint16 wxWord; #define SIZEOF_LONG 4 #define SIZEOF_WCHAR_T 2 - #define wxSIZE_T_IS_UINT + /* + under Win64 sizeof(size_t) == 8 and so it is neither unsigned + int nor unsigned long! + */ + #ifdef __WIN64__ + #define SIZEOF_SIZE_T 8 + + #undef wxSIZE_T_IS_UINT + #else /* Win32 */ + #define SIZEOF_SIZE_T 4 + + #define wxSIZE_T_IS_UINT + #endif #undef wxSIZE_T_IS_ULONG #ifdef __WIN64__ - #define SIZEOF_INT_P 8 + #define SIZEOF_VOID_P 8 #else /* Win32 */ - #define SIZEOF_INT_P 4 + #define SIZEOF_VOID_P 4 #endif /* Win64/32 */ #endif /* !defined(SIZEOF_INT) */ #else @@ -678,10 +681,14 @@ typedef wxUint16 wxWord; #error "Unknown sizeof(int) value, what are you compiling for?" #endif #else /* !defined(SIZEOF_INT) */ - /* assume sizeof(int) == 4 -- what else can we do? */ + /* assume default 32bit machine -- what else can we do? */ wxCOMPILE_TIME_ASSERT( sizeof(int) == 4, IntMustBeExactly4Bytes); + wxCOMPILE_TIME_ASSERT( sizeof(size_t) == 4, SizeTMustBeExactly4Bytes); + wxCOMPILE_TIME_ASSERT( sizeof(void *) == 4, PtrMustBeExactly4Bytes); #define SIZEOF_INT 4 + #define SIZEOF_SIZE_T 4 + #define SIZEOF_VOID_P 4 typedef int wxInt32; typedef unsigned int wxUint32; @@ -704,6 +711,22 @@ typedef wxUint16 wxWord; typedef wxUint32 wxDword; +/* + Define an integral type big enough to contain all of long, size_t and void *. + */ +#if SIZEOF_LONG >= SIZEOF_VOID_P && SIZEOF_LONG >= SIZEOF_SIZE_T + /* normal case */ + typedef unsigned long wxUIntPtr; +#elif SIZEOF_SIZE_T >= SIZEOF_VOID_P + /* Win64 case */ + typedef size_t wxUIntPtr; +#else + /* + This should never happen for the current architectures but if you're + using one where it does, please contact wx-dev@lists.wxwindows.org. + */ + #error "Pointers can't be stored inside integer types." +#endif /* 64 bit */ diff --git a/setup.h.in b/setup.h.in index fa0d1e1569..9ba2e844ff 100644 --- a/setup.h.in +++ b/setup.h.in @@ -1053,8 +1053,8 @@ /* The number of bytes in a int. */ #undef SIZEOF_INT -/* The number of bytes in a int *. */ -#undef SIZEOF_INT_P +/* The number of bytes in a pointer. */ +#undef SIZEOF_VOID_P /* The number of bytes in a long. */ #undef SIZEOF_LONG @@ -1065,6 +1065,9 @@ /* The number of bytes in a short. */ #undef SIZEOF_SHORT +/* The number of bytes in a size_t. */ +#undef SIZEOF_SIZE_T + /* Define if size_t on your machine is the same type as unsigned int. */ #undef wxSIZE_T_IS_UINT diff --git a/setup.h_vms b/setup.h_vms index 454e2b82ea..98f790c62f 100644 --- a/setup.h_vms +++ b/setup.h_vms @@ -1070,8 +1070,8 @@ /* The number of bytes in a int. */ #define SIZEOF_INT 4 -/* The number of bytes in a int *. */ -#define SIZEOF_INT_P 4 +/* The number of bytes in a pointer. */ +#define SIZEOF_VOID_P 4 /* The number of bytes in a long. */ #define SIZEOF_LONG 4 @@ -1082,6 +1082,9 @@ /* The number of bytes in a short. */ #define SIZEOF_SHORT 2 +/* The number of bytes in a size_t. */ +#define SIZEOF_SIZE_T 4 + /* Define if size_t on your machine is the same type as unsigned int. */ #define wxSIZE_T_IS_UINT 1 -- 2.47.2