[Kst] [Bug 74239] int datatype in kst plugins and data sources is not 64-bit clean

George Staikos staikos at kde.org
Fri Feb 6 05:41:21 CET 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=74239      




------- Additional Comments From staikos at kde.org  2004-02-06 05:41 -------
Subject: Re: [Kst]  New: int datatype in kst plugins and data sources is not 64-bit clean

Yes the plan is to use something similar to this approach...

On Thursday 05 February 2004 12:06, Ted Kisner wrote:
> I would recommend against ever explicitly using "long", as it can be either
> 32 or 64 bits depending on the platform.  What I've always done is use
> AC_CHECK_SIZEOF at build time to go through all standard C types and then
> define types that have a constant bit-width.
>
> Maybe there is an easier way to do this, but this is the best I've found...
>
> for example:
>
> configure.in
> --------------
> ...
> AC_CHECK_SIZEOF(int8,0)
> AC_CHECK_SIZEOF(int16,0)
> AC_CHECK_SIZEOF(int32,0)
> AC_CHECK_SIZEOF(int64,0)
> AC_CHECK_SIZEOF(uint8,0)
> AC_CHECK_SIZEOF(uint16,0)
> AC_CHECK_SIZEOF(uint32,0)
> AC_CHECK_SIZEOF(uint64,0)
> AC_CHECK_SIZEOF(float32,0)
> AC_CHECK_SIZEOF(float64,0)
> AC_CHECK_SIZEOF(char,0)
> AC_CHECK_SIZEOF(signed char,0)
> AC_CHECK_SIZEOF(unsigned char,0)
> AC_CHECK_SIZEOF(short int,0)
> AC_CHECK_SIZEOF(unsigned short int,0)
> AC_CHECK_SIZEOF(int,0)
> AC_CHECK_SIZEOF(unsigned int,0)
> AC_CHECK_SIZEOF(long int,0)
> AC_CHECK_SIZEOF(unsigned long int,0)
> AC_CHECK_SIZEOF(long long int,0)
> AC_CHECK_SIZEOF(unsigned long long int,0)
> AC_CHECK_SIZEOF(float,0)
> AC_CHECK_SIZEOF(double,0)
> ...
>
> Then, in some global header file
> ----------------------------------------------------
>
> /* set up some portable types of constant bit-width */
>
> #if SIZEOF_INT8 != 1
> #  undef int8
> #  if SIZEOF_SIGNED_CHAR == 1
> #    define int8 signed char
> #  elif SIZEOF_SHORT_INT == 1
> #    define int8 short int
> #  elif SIZEOF_INT == 1
> #    define int8 int
> #  elif SIZEOF_LONG_INT == 1
> #    define int8 long int
> #  elif SIZEOF_LONG_LONG_INT == 1
> #    define int8 long long int
> #  endif
> #endif
>
> #if SIZEOF_UINT8 != 1
> #  undef uint8
> #  if SIZEOF_UNSIGNED_CHAR == 1
> #    define uint8 unsigned char
> #  elif SIZEOF_UNSIGNED_SHORT_INT == 1
> #    define uint8 unsigned short int
> #  elif SIZEOF_UNSIGNED_INT == 1
> #    define uint8 unsigned int
> #  elif SIZEOF_UNSIGNED_LONG_INT == 1
> #    define uint8 unsigned long int
> #  elif SIZEOF_UNSIGNED_LONG_LONG_INT == 1
> #    define uint8 unsigned long long int
> #  endif
> #endif
>
> #if SIZEOF_INT16 != 2
> #  undef int16
> #  if SIZEOF_SIGNED_CHAR == 2
> #    define int16 signed char
> #  elif SIZEOF_SHORT_INT == 2
> #    define int16 short int
> #  elif SIZEOF_INT == 2
> #    define int16 int
> #  elif SIZEOF_LONG_INT == 2
> #    define int16 long int
> #  elif SIZEOF_LONG_LONG_INT == 2
> #    define int16 long long int
> #  endif
> #endif
>
> #if SIZEOF_UINT16 != 2
> #  undef uint16
> #  if SIZEOF_UNSIGNED_CHAR == 2
> #    define uint16 unsigned char
> #  elif SIZEOF_UNSIGNED_SHORT_INT == 2
> #    define uint16 unsigned short int
> #  elif SIZEOF_UNSIGNED_INT == 2
> #    define uint16 unsigned int
> #  elif SIZEOF_UNSIGNED_LONG_INT == 2
> #    define uint16 unsigned long int
> #  elif SIZEOF_UNSIGNED_LONG_LONG_INT == 2
> #    define uint16 unsigned long long int
> #  endif
> #endif
>
> #if SIZEOF_INT32 != 4
> #  undef int32
> #  if SIZEOF_SIGNED_CHAR == 4
> #    define int32 signed char
> #  elif SIZEOF_SHORT_INT == 4
> #    define int32 short int
> #  elif SIZEOF_INT == 4
> #    define int32 int
> #  elif SIZEOF_LONG_INT == 4
> #    define int32 long int
> #  elif SIZEOF_LONG_LONG_INT == 4
> #    define int32 long long int
> #  endif
> #endif
>
> #if SIZEOF_UINT32 != 4
> #  undef uint32
> #  if SIZEOF_UNSIGNED_CHAR == 4
> #    define uint32 unsigned char
> #  elif SIZEOF_UNSIGNED_SHORT_INT == 4
> #    define uint32 unsigned short int
> #  elif SIZEOF_UNSIGNED_INT == 4
> #    define uint32 unsigned int
> #  elif SIZEOF_UNSIGNED_LONG_INT == 4
> #    define uint32 unsigned long int
> #  elif SIZEOF_UNSIGNED_LONG_LONG_INT == 4
> #    define uint32 unsigned long long int
> #  endif
> #endif
>
> #if SIZEOF_INT64 != 8
> #  undef int64
> #  if SIZEOF_SIGNED_CHAR == 8
> #    define int64 signed char
> #  elif SIZEOF_SHORT_INT == 8
> #    define int64 short int
> #  elif SIZEOF_INT == 8
> #    define int64 int
> #  elif SIZEOF_LONG_INT == 8
> #    define int64 long int
> #  elif SIZEOF_LONG_LONG_INT == 8
> #    define int64 long long int
> #  endif
> #endif
>
> #if SIZEOF_UINT64 != 8
> #  undef uint64
> #  if SIZEOF_UNSIGNED_CHAR == 8
> #    define uint64 unsigned char
> #  elif SIZEOF_UNSIGNED_SHORT_INT == 8
> #    define uint64 unsigned short int
> #  elif SIZEOF_UNSIGNED_INT == 8
> #    define uint64 unsigned int
> #  elif SIZEOF_UNSIGNED_LONG_INT == 8
> #    define uint64 unsigned long int
> #  elif SIZEOF_UNSIGNED_LONG_LONG_INT == 8
> #    define uint64 unsigned long long int
> #  endif
> #endif
>
> #if SIZEOF_FLOAT32 != 4
> #  undef float32
> #  if SIZEOF_FLOAT == 4
> #    define float32 float
> #  elif SIZEOF_DOUBLE == 4
> #    define float32 double
> #  elif SIZEOF_LONG_DOUBLE == 4
> #    define float32 long double
> #  endif
> #endif
>
> #if SIZEOF_FLOAT64 != 8
> #  undef float64
> #  if SIZEOF_FLOAT == 8
> #    define float64 float
> #  elif SIZEOF_DOUBLE == 8
> #    define float64 double
> #  elif SIZEOF_LONG_DOUBLE == 8
> #    define float64 long double
> #  endif
> #endif
>
> Now you can use these types (float64, int32, etc) with confidence, knowing
> that they have the correct bitsize.



More information about the Kst mailing list