Page 1 of 1

PB-CTypeTable

Posted: Mon Dec 11, 2023 1:50 am
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

Re: PB-CTypeTable

Posted: Tue Dec 26, 2023 8:37 am
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 ?

Re: PB-CTypeTable

Posted: Tue Dec 26, 2023 12:50 pm
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

Re: PB-CTypeTable

Posted: Wed Dec 27, 2023 6:13 am
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.?

Re: PB-CTypeTable

Posted: Sat Dec 30, 2023 7:13 am
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.

Re: PB-CTypeTable

Posted: Mon Jan 15, 2024 11:54 am
by Denis
Your tools is useful.

I will take a deeper look but i don't know when :(

Re: PB-CTypeTable

Posted: Mon Jan 15, 2024 1:47 pm
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

Re: PB-CTypeTable

Posted: Mon Jan 15, 2024 11:31 pm
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.

Re: PB-CTypeTable

Posted: Tue Jan 23, 2024 5:03 am
by Inner
Add a video of the current state of the project, it's just easier/quicker at the moment.

Re: PB-CTypeTable

Posted: Tue Jan 23, 2024 4:14 pm
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 :)

Re: PB-CTypeTable

Posted: Tue Jan 23, 2024 4:43 pm
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 :)