tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Many new errors on RPi because of ssize_t incompatibl


From: Christian JULLIEN
Subject: Re: [Tinycc-devel] Many new errors on RPi because of ssize_t incompatible redefinition
Date: Wed, 26 Jul 2017 07:38:33 +0200 (CEST)

Here is the results of quick study for ptrdiff_t


VC++:

// Definitions of common types
#ifdef _WIN64
  typedef unsigned __int64 size_t;
  typedef __int64 ptrdiff_t;
  typedef __int64 intptr_t;
#else
  typedef unsigned int size_t;
  typedef int ptrdiff_t;
  typedef int intptr_t;
#endif

gcc 5.4.0 64bits on Windows:

ptrdiff_t: long int

size_t: long unsigned int


gcc 5.4.0 32bits on Windows:

ptrdiff_t: int

size_t: unsigned int


gcc 4.4.7 64bits on Linux x64:

ptrdiff_t: long int

size_t: long unsigned int


gcc 4.4.7 64bits on Linux x86:

ptrdiff_t: int

size_t: unsigned int


gcc 4.9.2 32bits on RPi

ptrdiff_t: int

size_t: unsigned int


Please note that VC++ does not define __PTRDIFF_TYPE__ __SIZE_TYPE__ which are gcc specific.


AT LEAST FOR 32bits, it looks safe to replace long -> int,. Fot PE it depends if we want to be VC++ compatible or gcc compatible. For other 64bits system I've no clear opinion atm.


Looks safe:


#else
  /* Other 32bit systems. */
  tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned int");
  tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");
  tcc_define_symbol(s, "__ILP32__", NULL);
#endif



Le : 25 juillet 2017 à 23:01 (GMT +02:00)
De : "Michael Matz" <address@hidden>
À : "address@hidden" <address@hidden>
Objet : Re: [Tinycc-devel] Many new errors on RPi because of ssize_t incompatible redefinition


Hi,

On Tue, 25 Jul 2017, grischka wrote:

> uso ewin wrote:
>> I guess ptrdiff_t should indeed be a long int, but ssize_t should be an
>> int,
>> same for intptr_t and uintptr_t should be an unsigned int.
>
> gcc 6.3.0 on win32 (32bits):
>
> test.c:9:14: error: '_Generic' selector of type 'int' is not compatible with
> any association
> _Generic((ptrdiff_t)0, void*:0);
> ^
>
> So at least this gcc thinks that ptrdiff_t is of type 'int'.

You can definitely find out with:

% echo __PTRDIFF_TYPE__ | gcc -E

That is the value that tcc must use as well (and then stddef.h is supposed
to simply use that macro, but only to define ptrdiff_t, not any related
types, which shouldn't come from stddef.h at all actually). And yes,
GCCs use 'int' for -m32 normally and 'long int' for -m64.

So the state with commit 28b7c9 was actually correct and was unfixed with
the later 52622c.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]