Page 1 of 2

C++ to PB

Posted: Thu Nov 16, 2023 7:43 pm
by Patrice Terrier
Does there is a utility to convert a C++ header (external DLL declaration) into PureBasic?

Re: C++ to PB

Posted: Thu Nov 16, 2023 8:19 pm
by Kuron
Not that I am aware of, but that does not mean it doesn't exist. It would be a very handy thing.

Re: C++ to PB

Posted: Thu Nov 16, 2023 9:02 pm
by Kuron
I just browsed http://purearea.net/pb/english/index.htm and did not see anything that stood out.

Re: C++ to PB

Posted: Thu Nov 16, 2023 11:34 pm
by AZJIO
PureBasic\SDK\Header Converter\Header Converter.exe

Re: C++ to PB

Posted: Fri Nov 17, 2023 1:48 pm
by Patrice Terrier
Thank you for the answers.

Unfortunatly I couldn't get "Header Converter.exe" to work with my C++ Visual Studio 2022 headers.

Re: C++ to PB

Posted: Thu Nov 30, 2023 3:19 pm
by Inner
Patrice Terrier wrote: Fri Nov 17, 2023 1:48 pm Thank you for the answers.

Unfortunatly I couldn't get "Header Converter.exe" to work with my C++ Visual Studio 2022 headers.
I couldn't get it to convert a C header or maybe we're not understanding "Header Converter.exe" and it's intended purpose, it might be for just general purpose header conversions that doesn't take into account the nuances of more complex headers and it's bailing out, as I've given it a header output folders not sure what 'validation files path' is in aide of at a guess it might be something to cross check structures or what have you are of the right sizes, but as I said I've not been able to get it to output anything, is the source available for header converter.exe?

Re: C++ to PB

Posted: Thu Nov 30, 2023 3:23 pm
by Fred
It's a very old tool which was useful at time to mass convert constants and structs, but it's probably not working anymore with current headers. I will remove it from the SDK

Re: C++ to PB

Posted: Thu Nov 30, 2023 5:35 pm
by mk-soft
Fred wrote: Thu Nov 30, 2023 3:23 pm It's a very old tool which was useful at time to mass convert constants and structs, but it's probably not working anymore with current headers. I will remove it from the SDK
Why remove it, you can still use it for old header files.

Re: C++ to PB

Posted: Thu Nov 30, 2023 8:17 pm
by idle
If people insert beer I will write a header converter, I have already scoped out a solution a few months ago that will work but I've not had the motivation to do it and I was waiting to see where Fred's heading with 6.10 but I've come to the conclusion an auto importer would actually be more beneficial than including c directly as it requires a full c compiler suite or at least the right system headers. It will take around 6 to 8 weeks to do. But will probably get results in a week it's dealing with edge cases and ambiguities that will take time as you've got to find them.

Re: C++ to PB

Posted: Thu Nov 30, 2023 8:19 pm
by mk-soft
@Idle,
Where should I send the beer :?: 8)

Re: C++ to PB

Posted: Thu Nov 30, 2023 8:36 pm
by idle
mk-soft wrote: Thu Nov 30, 2023 8:19 pm @Idle,
Where should I send the beer :?: 8)
Pour it in the funnel that's attached to the hose in my mouth.

Re: C++ to PB

Posted: Thu Nov 30, 2023 11:53 pm
by normeus
Beer+ ( generic beer, unless there is a specific place/brand for said pitcher/Barrel of beer)

Re: C++ to PB

Posted: Fri Dec 01, 2023 2:23 am
by Inner
idle wrote: Thu Nov 30, 2023 8:17 pm If people insert beer I will write a header converter, I have already scoped out a solution a few months ago that will work but I've not had the motivation to do it and I was waiting to see where Fred's heading with 6.10 but I've come to the conclusion an auto importer would actually be more beneficial than including c directly as it requires a full c compiler suite or at least the right system headers. It will take around 6 to 8 weeks to do. But will probably get results in a week it's dealing with edge cases and ambiguities that will take time as you've got to find them.
now that would be of immense help I'm (as you might know) forever trying to 'Purify' all sorts of .libs/.dlls the most time consuming part is converting .h files their a nightmare when you don't exactly know what a type a variable is supposed to be, sometimes it's like a treasure hunt trying to nail down what someone has typedef as lollipop only to discover an hour later that it's simply at unsigned int :x

if I understand 6.10 direction properly it sounds like when I've simplified it down to being just able to include .lib files as is, which will still require some sort of .h translation for structs, constants, enums and so on anyway, I've thought about it myself from time to time over the years I left it for a more skilled programmer to do as it's quite an involved project which requires a god like understanding of C.

Re: C++ to PB

Posted: Fri Dec 01, 2023 4:26 am
by idle
Inner wrote: Fri Dec 01, 2023 2:23 am
idle wrote: Thu Nov 30, 2023 8:17 pm If people insert beer I will write a header converter, I have already scoped out a solution a few months ago that will work but I've not had the motivation to do it and I was waiting to see where Fred's heading with 6.10 but I've come to the conclusion an auto importer would actually be more beneficial than including c directly as it requires a full c compiler suite or at least the right system headers. It will take around 6 to 8 weeks to do. But will probably get results in a week it's dealing with edge cases and ambiguities that will take time as you've got to find them.
now that would be of immense help I'm (as you might know) forever trying to 'Purify' all sorts of .libs/.dlls the most time consuming part is converting .h files their a nightmare when you don't exactly know what a type a variable is supposed to be, sometimes it's like a treasure hunt trying to nail down what someone has typedef as lollipop only to discover an hour later that it's simply at unsigned int :x

if I understand 6.10 direction properly it sounds like when I've simplified it down to being just able to include .lib files as is, which will still require some sort of .h translation for structs, constants, enums and so on anyway, I've thought about it myself from time to time over the years I left it for a more skilled programmer to do as it's quite an involved project which requires a god like understanding of C.
I don't know what Fred's doing yet but I've recently come to the conclusion that trying to import c libs with my hacks doesn't always work which I think is a conflict between the c system headers what gcc expects vs mingw llvm, so we would need a copy of the c headers and c system headers for that to work. I've found a couple of ways to get the required information to do the job but I'm still not 100% decided on which way to go. One needs a llvm install and the other is a stand alone tool based on llvm tools. It's output isn't exactly human friendly to read but it'll be fine in code

Re: C++ to PB

Posted: Fri Dec 01, 2023 3:28 pm
by Inner
idle wrote: Fri Dec 01, 2023 4:26 am
Inner wrote: Fri Dec 01, 2023 2:23 am
idle wrote: Thu Nov 30, 2023 8:17 pm If people insert beer I will write a header converter, I have already scoped out a solution a few months ago that will work but I've not had the motivation to do it and I was waiting to see where Fred's heading with 6.10 but I've come to the conclusion an auto importer would actually be more beneficial than including c directly as it requires a full c compiler suite or at least the right system headers. It will take around 6 to 8 weeks to do. But will probably get results in a week it's dealing with edge cases and ambiguities that will take time as you've got to find them.
now that would be of immense help I'm (as you might know) forever trying to 'Purify' all sorts of .libs/.dlls the most time consuming part is converting .h files their a nightmare when you don't exactly know what a type a variable is supposed to be, sometimes it's like a treasure hunt trying to nail down what someone has typedef as lollipop only to discover an hour later that it's simply at unsigned int :x

if I understand 6.10 direction properly it sounds like when I've simplified it down to being just able to include .lib files as is, which will still require some sort of .h translation for structs, constants, enums and so on anyway, I've thought about it myself from time to time over the years I left it for a more skilled programmer to do as it's quite an involved project which requires a god like understanding of C.
I don't know what Fred's doing yet but I've recently come to the conclusion that trying to import c libs with my hacks doesn't always work which I think is a conflict between the c system headers what gcc expects vs mingw llvm, so we would need a copy of the c headers and c system headers for that to work. I've found a couple of ways to get the required information to do the job but I'm still not 100% decided on which way to go. One needs a llvm install and the other is a stand alone tool based on llvm tools. It's output isn't exactly human friendly to read but it'll be fine in code
Ideally the most perfect path from one perspective is not to need converting anything at all just include use and abuse :shock: :o :D I thought when I heard the news that there was a C backend to PB that was the general goal post PB was aiming at, it'd be nice for it to be the case though as one man or is it 3 now cannot be all things to all people for all features, but being able to drop sdks into PB from whatever source they might come from would be the ideal solution, realizing of course that this would make one of my own projects defunct (RML) but I'd rather that loss and more expandable language. I'm a bit jealous of C/C#/C++ they get all the fun toys but I'm also not willing to put up with the mind numbing headaches those languages would ensue, besides PB is better than those languages :P