C to PureBasic Transpiler

Everything else that doesn't fall into one of the other PB categories.
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: C to PureBasic Transpiler

Post 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
The Stone Age did not end due to a shortage of stones !
User avatar
idle
Always Here
Always Here
Posts: 5096
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C to PureBasic Transpiler

Post by idle »

I will try later
User avatar
idle
Always Here
Always Here
Posts: 5096
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C to PureBasic Transpiler

Post 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
User avatar
fsw
Addict
Addict
Posts: 1572
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: C to PureBasic Transpiler

Post 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.
Last edited by fsw on Sun Apr 03, 2022 7:30 am, edited 2 times in total.

I am to provide the public with beneficial shocks.
Alfred Hitshock
breeze4me
Enthusiast
Enthusiast
Posts: 527
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: C to PureBasic Transpiler

Post 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]
User avatar
fsw
Addict
Addict
Posts: 1572
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: C to PureBasic Transpiler

Post by fsw »

Thank you breeze.
Changed the table accordingly...

I am to provide the public with beneficial shocks.
Alfred Hitshock
Justin
Addict
Addict
Posts: 832
Joined: Sat Apr 26, 2003 2:49 pm

Re: C to PureBasic Transpiler

Post 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.
User avatar
fsw
Addict
Addict
Posts: 1572
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: C to PureBasic Transpiler

Post 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.

I am to provide the public with beneficial shocks.
Alfred Hitshock
Justin
Addict
Addict
Posts: 832
Joined: Sat Apr 26, 2003 2:49 pm

Re: C to PureBasic Transpiler

Post 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.
User avatar
fsw
Addict
Addict
Posts: 1572
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: C to PureBasic Transpiler

Post 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.

I am to provide the public with beneficial shocks.
Alfred Hitshock
Post Reply