reorganized/improved fixed size int types definitions; in particular use __int64 for wxInt64 if available
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23817 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -689,68 +689,197 @@ enum
|
|||||||
#endif // Win16/!Win16
|
#endif // Win16/!Win16
|
||||||
#endif // wxUSE_COMPATIBLE_COORD_TYPES/!wxUSE_COMPATIBLE_COORD_TYPES
|
#endif // wxUSE_COMPATIBLE_COORD_TYPES/!wxUSE_COMPATIBLE_COORD_TYPES
|
||||||
|
|
||||||
// fixed length types
|
|
||||||
|
|
||||||
#define wxInt8 char signed
|
// ----------------------------------------------------------------------------
|
||||||
#define wxUint8 char unsigned
|
// define fixed length types
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
// chars are always one byte (by definition), shorts are always two (in
|
||||||
#if defined(__WIN16__)
|
// practice)
|
||||||
#define wxInt16 int signed
|
|
||||||
#define wxUint16 int unsigned
|
// 8bit
|
||||||
#define wxInt32 long signed
|
#ifndef SIZEOF_CHAR
|
||||||
#define wxUint32 long unsigned
|
#define SIZEOF_CHAR 1
|
||||||
#elif defined(__WIN32__)
|
#endif
|
||||||
#define wxInt16 short signed
|
typedef signed char wxInt8;
|
||||||
#define wxUint16 short unsigned
|
typedef unsigned char wxUint8;
|
||||||
#define wxInt32 int signed
|
typedef wxUint8 wxByte;
|
||||||
#define wxUint32 int unsigned
|
|
||||||
|
|
||||||
|
// 16bit
|
||||||
|
#ifdef SIZEOF_SHORT
|
||||||
|
#if SIZEOF_SHORT != 2
|
||||||
|
#error "wxWindows assumes sizeof(short) == 2, please fix the code"
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
// Win64 will have different type sizes
|
#define SIZEOF_SHORT 2
|
||||||
#error "Please define a 32 bit type"
|
#endif
|
||||||
|
|
||||||
|
typedef signed short wxInt16;
|
||||||
|
typedef unsigned short wxUint16;
|
||||||
|
|
||||||
|
typedef wxUint16 wxWord;
|
||||||
|
|
||||||
|
/*
|
||||||
|
things are getting more interesting with ints, longs and pointers
|
||||||
|
|
||||||
|
there are several different standard data models described by this table:
|
||||||
|
|
||||||
|
+-----------+----------------------------+
|
||||||
|
|type\model | LP64 ILP64 LLP64 ILP32 LP32|
|
||||||
|
+-----------+----------------------------+
|
||||||
|
|char | 8 8 8 8 8 |
|
||||||
|
|short | 16 16 16 16 16 |
|
||||||
|
|int | 32 64 32 32 16 |
|
||||||
|
|long | 64 64 32 32 32 |
|
||||||
|
|long long | 64 |
|
||||||
|
|void * | 64 64 64 32 32 |
|
||||||
|
+-----------+----------------------------+
|
||||||
|
|
||||||
|
Win16 used LP32 (but we don't support it any longer), Win32 obviously used
|
||||||
|
ILP32 and Win64 uses LLP64 (a.k.a. P64)
|
||||||
|
|
||||||
|
Under Unix LP64 is the most widely used (the only I've ever seen, in fact)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 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__)
|
||||||
|
typedef int wxInt32;
|
||||||
|
typedef unsigned int wxUint32;
|
||||||
|
|
||||||
|
// conside that if SIZEOF_INT is defined, all the other ones are too
|
||||||
|
#ifndef SIZEOF_INT
|
||||||
|
#define SIZEOF_INT 4
|
||||||
|
#define SIZEOF_LONG 4
|
||||||
|
#define SIZEOF_WCHAR_T 2
|
||||||
|
|
||||||
|
#define wxSIZE_T_IS_UINT
|
||||||
|
#undef wxSIZE_T_IS_ULONG
|
||||||
|
|
||||||
|
#ifdef __WIN64__
|
||||||
|
#define SIZEOF_INT_P 8
|
||||||
|
#else // Win32
|
||||||
|
#define SIZEOF_INT_P 4
|
||||||
|
#endif // Win64/32
|
||||||
|
#endif // !defined(SIZEOF_INT)
|
||||||
|
#else
|
||||||
|
#error "Unsupported Windows version"
|
||||||
#endif
|
#endif
|
||||||
#else // !Windows
|
#else // !Windows
|
||||||
// SIZEOF_XXX are defined by configure
|
// SIZEOF_XXX are normally defined by configure
|
||||||
#if defined(SIZEOF_INT) && (SIZEOF_INT == 4)
|
#ifdef SIZEOF_INT
|
||||||
#define wxInt16 short signed
|
#if SIZEOF_INT == 8
|
||||||
#define wxUint16 short unsigned
|
// must be ILP64 data model, there is normally a special 32 bit
|
||||||
#define wxInt32 int signed
|
// type in it but we don't know what it is...
|
||||||
#define wxUint32 int unsigned
|
#error "No 32bit int type on this platform"
|
||||||
#elif defined(SIZEOF_INT) && (SIZEOF_INT == 2)
|
#elif SIZEOF_INT == 4
|
||||||
#define wxInt16 int signed
|
typedef int wxInt32;
|
||||||
#define wxUint16 int unsigned
|
typedef unsigned int wxUint32;
|
||||||
#define wxInt32 long signed
|
#elif SIZEOF_INT == 2
|
||||||
#define wxUint32 long unsigned
|
// must be LP32
|
||||||
#else
|
#if SIZEOF_LONG != 4
|
||||||
// assume sizeof(int) == 4 - what else can we do
|
#error "No 32bit int type on this platform"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef long wxInt32;
|
||||||
|
typedef unsigned long wxUint32;
|
||||||
|
#elif
|
||||||
|
// wxWindows is not ready for 128bit systems yet...
|
||||||
|
#error "Unknown sizeof(int) value, what are you compiling for?"
|
||||||
|
#endif
|
||||||
|
#else // !defined(SIZEOF_INT)
|
||||||
|
// assume sizeof(int) == 4 -- what else can we do?
|
||||||
wxCOMPILE_TIME_ASSERT( sizeof(int) == 4, IntMustBeExactly4Bytes);
|
wxCOMPILE_TIME_ASSERT( sizeof(int) == 4, IntMustBeExactly4Bytes);
|
||||||
|
|
||||||
#define wxInt16 short signed
|
#define SIZEOF_INT 4
|
||||||
#define wxUint16 short unsigned
|
|
||||||
#define wxInt32 int signed
|
typedef int wxInt32;
|
||||||
#define wxUint32 int unsigned
|
typedef unsigned int wxUint32;
|
||||||
|
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
|
// also assume that sizeof(wchar_t) == 4 under Unix, this is by far
|
||||||
|
// the most common case
|
||||||
|
wxCOMPILE_TIME_ASSERT( sizeof(wchar_t) == 4,
|
||||||
|
Wchar_tMustBeExactly4Bytes);
|
||||||
|
#endif // wxUSE_WCHAR_T
|
||||||
#endif
|
#endif
|
||||||
#endif // Win/!Win
|
#endif // Win/!Win
|
||||||
|
|
||||||
|
typedef wxUint32 wxDword;
|
||||||
|
|
||||||
|
|
||||||
|
// 64 bit
|
||||||
|
|
||||||
|
// NB: we #define and not typedef wxLongLong_t because we want to be able to
|
||||||
|
// use 'unsigned wxLongLong_t' as well and because we use "#ifdef
|
||||||
|
// wxLongLong_t" in wx/longlong.h
|
||||||
|
|
||||||
|
// to avoid compilation problems on 64bit machines with ambiguous method calls
|
||||||
|
// we will need to define this
|
||||||
|
#undef wxLongLongIsLong
|
||||||
|
|
||||||
|
// first check for generic cases which are long on 64bit machine and "long
|
||||||
|
// long", then check for specific compilers
|
||||||
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||||
#define wxInt64 long signed
|
#define wxLongLong_t long
|
||||||
#define wxUint64 long unsigned
|
#define wxLongLongSuffix l
|
||||||
#elif defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
|
#define wxLongLongFmtSpec _T("l")
|
||||||
#define wxInt64 long long signed
|
#define wxLongLongIsLong
|
||||||
#define wxUint64 long long unsigned
|
#elif (defined(__VISUALC__) && defined(__WIN32__)) || defined( __VMS__ )
|
||||||
#else // FIXME: what else can we do here aside from implementing wxULongLong
|
#define wxLongLong_t __int64
|
||||||
#define wxInt64 wxLongLong
|
#define wxLongLongSuffix i64
|
||||||
#define wxUint64 wxULongLong
|
#define wxLongLongFmtSpec _T("I64")
|
||||||
|
#elif defined(__BORLANDC__) && defined(__WIN32__) && (__BORLANDC__ >= 0x520)
|
||||||
|
#define wxLongLong_t __int64
|
||||||
|
#define wxLongLongSuffix i64
|
||||||
|
#define wxLongLongFmtSpec _T("Ld")
|
||||||
|
#elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8) || \
|
||||||
|
defined(__MINGW32__) || \
|
||||||
|
defined(__GNUC__) || \
|
||||||
|
defined(__CYGWIN__) || \
|
||||||
|
defined(__WXMICROWIN__) || \
|
||||||
|
(defined(__DJGPP__) && __DJGPP__ >= 2)
|
||||||
|
#define wxLongLong_t long long
|
||||||
|
#define wxLongLongSuffix ll
|
||||||
|
#define wxLongLongFmtSpec _T("ll")
|
||||||
|
#elif defined(__MWERKS__)
|
||||||
|
#if __option(longlong)
|
||||||
|
#define wxLongLong_t long long
|
||||||
|
#define wxLongLongSuffix ll
|
||||||
|
#define wxLongLongFmtSpec _T("ll")
|
||||||
|
#else
|
||||||
|
#error "The 64 bit integer support in CodeWarrior has been disabled."
|
||||||
|
#error "See the documentation on the 'longlong' pragma."
|
||||||
|
#endif
|
||||||
|
#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
||||||
|
#define wxLongLong_t long long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef wxLongLong_t
|
||||||
|
typedef wxLongLong_t wxInt64;
|
||||||
|
typedef unsigned wxLongLong_t wxUint64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define wxByte wxUint8
|
|
||||||
#define wxWord wxUint16
|
|
||||||
|
|
||||||
// base floating point types
|
// base floating point types
|
||||||
// wxFloat32: 32 bit IEEE float ( 1 sign, 8 exponent bits, 23 fraction bits
|
// wxFloat32: 32 bit IEEE float ( 1 sign, 8 exponent bits, 23 fraction bits
|
||||||
// wxFloat64: 64 bit IEEE float ( 1 sign, 11 exponent bits, 52 fraction bits
|
// wxFloat64: 64 bit IEEE float ( 1 sign, 11 exponent bits, 52 fraction bits
|
||||||
// wxDouble: native fastest representation that has at least wxFloat64
|
// wxDouble: native fastest representation that has at least wxFloat64
|
||||||
// precision, so use the IEEE types for storage , and this for calculations
|
// precision, so use the IEEE types for storage, and this for
|
||||||
|
// calculations
|
||||||
|
|
||||||
typedef float wxFloat32;
|
typedef float wxFloat32;
|
||||||
#if (defined( __WXMAC__ ) || defined(__WXCOCOA__)) && defined (__MWERKS__)
|
#if (defined( __WXMAC__ ) || defined(__WXCOCOA__)) && defined (__MWERKS__)
|
||||||
|
@@ -38,50 +38,7 @@
|
|||||||
// decide upon which class we will use
|
// decide upon which class we will use
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// to avoid compilation problems on 64bit machines with ambiguous method calls
|
#ifndef wxLongLong_t
|
||||||
// we will need to define this
|
|
||||||
#undef wxLongLongIsLong
|
|
||||||
|
|
||||||
// NB: we #define and not typedef wxLongLong_t because we want to be able to
|
|
||||||
// use 'unsigned wxLongLong_t' as well and because we use "#ifdef
|
|
||||||
// wxLongLong_t" below
|
|
||||||
|
|
||||||
// first check for generic cases which are long on 64bit machine and "long
|
|
||||||
// long", then check for specific compilers
|
|
||||||
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
|
||||||
#define wxLongLong_t long
|
|
||||||
#define wxLongLongSuffix l
|
|
||||||
#define wxLongLongFmtSpec _T("l")
|
|
||||||
#define wxLongLongIsLong
|
|
||||||
#elif (defined(__VISUALC__) && defined(__WIN32__)) || defined( __VMS__ )
|
|
||||||
#define wxLongLong_t __int64
|
|
||||||
#define wxLongLongSuffix i64
|
|
||||||
#define wxLongLongFmtSpec _T("I64")
|
|
||||||
#elif defined(__BORLANDC__) && defined(__WIN32__) && (__BORLANDC__ >= 0x520)
|
|
||||||
#define wxLongLong_t __int64
|
|
||||||
#define wxLongLongSuffix i64
|
|
||||||
#define wxLongLongFmtSpec _T("Ld")
|
|
||||||
#elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8) || \
|
|
||||||
defined(__MINGW32__) || \
|
|
||||||
defined(__GNUC__) || \
|
|
||||||
defined(__CYGWIN__) || \
|
|
||||||
defined(__WXMICROWIN__) || \
|
|
||||||
(defined(__DJGPP__) && __DJGPP__ >= 2)
|
|
||||||
#define wxLongLong_t long long
|
|
||||||
#define wxLongLongSuffix ll
|
|
||||||
#define wxLongLongFmtSpec _T("ll")
|
|
||||||
#elif defined(__MWERKS__)
|
|
||||||
#if __option(longlong)
|
|
||||||
#define wxLongLong_t long long
|
|
||||||
#define wxLongLongSuffix ll
|
|
||||||
#define wxLongLongFmtSpec _T("ll")
|
|
||||||
#else
|
|
||||||
#error "The 64 bit integer support in CodeWarrior has been disabled."
|
|
||||||
#error "See the documentation on the 'longlong' pragma."
|
|
||||||
#endif
|
|
||||||
#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
|
||||||
#define wxLongLong_t long long
|
|
||||||
#else // no native long long type
|
|
||||||
// both warning and pragma warning are not portable, but at least an
|
// both warning and pragma warning are not portable, but at least an
|
||||||
// unknown pragma should never be an error -- except that, actually, some
|
// unknown pragma should never be an error -- except that, actually, some
|
||||||
// broken compilers don't like it, so we have to disable it in this case
|
// broken compilers don't like it, so we have to disable it in this case
|
||||||
|
Reference in New Issue
Block a user