PB-CTypeTable

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

PB-CTypeTable

Post by Inner »

#PureBasic Tool for the Tools Menu

It's intended use is a reference of Pure Basic Variable Types and a reference for how C type variables convert to Pure Basic, additionally when I write the code it may convert 'a' C type variable into a Pure Basic one.

https://github.com/melony-cmd/PB-CTypeTable

note: currently you'll probably need to (manually) re-path the images I'm using as for some reason 'Form Designer' doesn't like relative paths and wants a full path instead, which is "ok" for me not so "ok" for anyone else.

- version 0.0.1a
Added: Header Assistant

https://www.youtube.com/watch?v=fodzfgLNQCY - video of current progress of project
Last edited by Inner on Tue Jan 23, 2024 5:02 am, edited 2 times in total.
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB-CTypeTable

Post by Denis »

Hi Inner,

I'm no C language guru, but when I saw in your tool that a variable of type long has a size of 8 byte, I thought there was an error.

With VisualStudio 2022, I wrote the following code (console mode) :

Code: Select all


#include <iostream>
#include <windows.h>
#include <commCtrl.h>
#include <winuser.h>


#define PRINTF_SIZEOF(type) printf("  SizeOf( "  #type  " ) = %zu\n", sizeof(type))
#define PRINTF_OffsetOf(type,member) printf("  OffsetOf( "  #member  " ) = %zu\n", offsetof(type,member))
#define PRINTF_Normal(type) printf("  IS_INTRESOURCE( "  #type  " ) = %zu\n", (type))


int main()
{
#ifdef UNICODE


#if defined(_WIN64)
	printf("\n");
	printf("\n");
	printf("  Compilation Window 64 bit - mode unicode\n");
#else
	printf("\n");
	printf("\n");
	printf("  Compilation Window 32 bit - mode unicode\n");
#endif



	LONG essai;
	long essai_2;


	printf(" LONG essai;\n");
	PRINTF_SIZEOF(essai);
	printf(" long essai_2;\n");
	PRINTF_SIZEOF(essai_2);



#else
	printf("You must compile in unicode mode!\n");
#endif


	return 0;
}
As a result i get a sizeOf 4 byte (x86 and x64) which matchs to Microsoft's definition of Long Type :
https://learn.microsoft.com/en-us/windo ... types#LONG

Am I wrong ?
A+
Denis
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB-CTypeTable

Post by mk-soft »

Attention!

On Window x86/x64 is LONG 4 bytes
On macOS x86 and Linux x86 is LONG 4 bytes
On macOS x64 and Linux x64 is LONG 8 bytes

Code: Select all

CompilerIf Not #PB_Compiler_Backend = #PB_Backend_C
  CompilerError "Use C-Backend!"
CompilerEndIf

Global size
! g_size = sizeof(long);
Debug size
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB-CTypeTable

Post by Denis »

Thanks mk-soft for clarification!
I only work on Windows (x86-64) with Intel microp, so I didn't specify it.

Here's a link to Microsoft Data Type Ranges :
https://learn.microsoft.com/en-us/cpp/c ... w=msvc-170

Do you have other links for linux , macOS for C types etc.?
A+
Denis
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Re: PB-CTypeTable

Post by Inner »

Denis wrote: Wed Dec 27, 2023 6:13 am Do you have other links for linux , macOS for C types etc.?
Shouldn't they be all the same regardless of OS? I could understand MacOS being different though because well MacOS.. not like they keep to a standard or anything.

Either; way need looking into maybe a column for Operating System and or CPU Architecture? the "PureBasic Types" / "C Types" tabs intention was/is to allow the additions and alterations by the user, admittedly I've not been around that code in a little while so it might not be implemented yet as I've been working on the header assistant part of the application, of which I just did a commit to github.
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB-CTypeTable

Post by Denis »

Your tools is useful.

I will take a deeper look but i don't know when :(
A+
Denis
highend
Enthusiast
Enthusiast
Posts: 123
Joined: Tue Jun 17, 2014 4:49 pm

Re: PB-CTypeTable

Post by highend »

@Inner

Don't know if you care or not, but on the github page you have two occurrences of the word "veriable".
Maybe you want to correct them to "variable" :D
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Re: PB-CTypeTable

Post by Inner »

highend wrote: Mon Jan 15, 2024 1:47 pm @Inner

Don't know if you care or not, but on the github page you have two occurrences of the word "veriable".
Maybe you want to correct them to "variable" :D
:arrow: Dyslexia for the W .. I swear last night I was looking at the alphabet because I forgot it's order (hadn't slept in 48hrs)

--- and fixed.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Re: PB-CTypeTable

Post by Inner »

Add a video of the current state of the project, it's just easier/quicker at the moment.
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PB-CTypeTable

Post by ChrisR »

I don't know anything about the C language, so this should be a great help for getting started and going further.
It looks like a big and nice piece of work, I'll be following you closely :)
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Re: PB-CTypeTable

Post by Inner »

ChrisR wrote: Tue Jan 23, 2024 4:14 pm I don't know anything about the C language, so this should be a great help for getting started and going further.
It looks like a big and nice piece of work, I'll be following you closely :)
It's a nightmare, others including myself have tried through many private iterations and attempts to find a solution that can automatically convert .h files to something PureBasic can consume, why? well manually converting .h files is monumentally time consuming (also prone to mistakes) and they are dependent (from my perspective) for any constructive use of external libraries be they .lib or .dll, even worse when you have to remember a pile of junk about a language that (again from my point of view) should have had its day already we should be using a 'basic' style language these days, not over complicating things, hence why I am PB Fan.

It would be nice if we could just IncludeHFile "blar.h", but I doubt that day will ever come, so we'll just have to do it the hard way :)
Post Reply