Page 2 of 2

Re: C to PureBasic Transpiler

Posted: Thu Mar 31, 2022 11:00 pm
by StarBootics
idle wrote: Thu Mar 31, 2022 7:59 pm You can use unsigned types now in c backend but you need to redefine the variables in c.
https://www.purebasic.fr/english/viewtopic.php?t=78386
Did you find the way to define structure members as unsigned types ?

Best regards
StarBootics

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 12:54 am
by idle
I will try later

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 7:58 am
by idle
StarBootics wrote: Thu Mar 31, 2022 11:00 pm
idle wrote: Thu Mar 31, 2022 7:59 pm You can use unsigned types now in c backend but you need to redefine the variables in c.
https://www.purebasic.fr/english/viewtopic.php?t=78386
Did you find the way to define structure members as unsigned types ?

Best regards
StarBootics
I need to look into that more, I'm away for the weekend

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 6:16 pm
by fsw
I've compiled a list of data types sizes for different operating systems.
In case there is some interest...

Code: Select all

			 Unix 32	 Unix 64	Linux 32	Linux 64	macOS 32	macOS 64	 Win 32		 Win 64		Notes
char		 1 byte		 1 byte		 1 byte		 1 byte		 1 byte		 1 byte		 1 byte		 1 byte	
short		 2 bytes	 2 bytes	 2 bytes	 2 bytes	 2 bytes	 2 bytes	 2 bytes	 2 bytes	
int			 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	
long		 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 4 bytes	
long long	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	
float		 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	1 bit sign, 8 bit exp, 23 bit mantissa
double		 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	 8 bytes	1 bit sign, 11 bit exp, 52 bit mantissa
long double	16 bytes	16 bytes	16 bytes	16 bytes	16 bytes	16 bytes	 8 bytes	 8 bytes	1 bit sign, 15 bit exp, 112 bit mantissa IEE754 (same as double on Windows)
pointer		 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	
ptrdiff_t	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 8 bytes	 8 bytes	
size_t		 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 8 bytes	 8 bytes	
time_t		 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 8 bytes	 8 bytes	
clock_t		 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 8 bytes	 4 bytes	 4 bytes	
wchar_t		 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 4 bytes	 2 bytes	 2 bytes	
WORD														 						 2 bytes	 2 bytes	Windows only
DWORD														 						 4 bytes	 4 bytes	Windows only
HANDLE														 						 4 bytes	 8 bytes	Windows only
HFILE														 						 4 bytes	 4 bytes	Windows only

Please let me know if you find a mistake or think something is missing.

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 7:15 pm
by breeze4me
fsw wrote: Fri Apr 01, 2022 6:16 pm I'm not quite sure about the long double, as I've seen it as 80 bit and 128 bit...
On Windows I found a size of 8 bytes for the long double, but it can't be right, can't it?

Please let me know if you find a mistake or think something is missing.
MS compiler always considers the "lond double" type to be "double".
Read the articles below.

Type long double
Data Type Ranges
Why did Microsoft abandon long double data type? [closed]

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 7:19 pm
by fsw
Thank you breeze.
Changed the table accordingly...

Re: C to PureBasic Transpiler

Posted: Fri Apr 01, 2022 9:57 pm
by Justin
HANDLE is a pointer so i would say is 4 bytes on x32 and 8 bytes on X64 although i have not checked it.

Re: C to PureBasic Transpiler

Posted: Sat Apr 02, 2022 12:58 am
by fsw
Justin wrote: Fri Apr 01, 2022 9:57 pm HANDLE is a pointer so i would say is 4 bytes on x32 and 8 bytes on X64 although i have not checked it.
MSDN says:
The following techniques can be used for communication between 32-bit and 64-bit applications:

64-bit versions of Windows use 32-bit handles for interoperability. When sharing a handle between 32-bit and 64-bit applications, only the lower 32 bits are significant, so it is safe to truncate the handle (when passing it from 64-bit to 32-bit) or sign-extend the handle (when passing it from 32-bit to 64-bit). Handles that can be shared include handles to user objects such as windows (HWND), handles to GDI objects such as pens and brushes (HBRUSH and HPEN), and handles to named objects such as mutexes, semaphores, and file handles.

Re: C to PureBasic Transpiler

Posted: Sat Apr 02, 2022 10:22 am
by Justin
hi fsw,
that text refers to interoperability but i think the actual sizes are 4 and 8, in visual studio sizeof(HANDLE) returns 4 on x86 and 8 in x64.
same with all handles that are pointers.

Re: C to PureBasic Transpiler

Posted: Sat Apr 02, 2022 5:23 pm
by juergenkulow

Re: C to PureBasic Transpiler

Posted: Sun Apr 03, 2022 7:31 am
by fsw
Justin wrote: Sat Apr 02, 2022 10:22 am hi fsw,
that text refers to interoperability but i think the actual sizes are 4 and 8, in visual studio sizeof(HANDLE) returns 4 on x86 and 8 in x64.
same with all handles that are pointers.
Thank you Justin.
List corrected.