c header files
c header files
Just a thought, since the backend is now gcc, would it be possible to support c header (.h) files? Or is there a conversion utility that will convert them to pb syntax?
Re: c header files
There sadly isn't native support for this in the compiler yet, although I would love to see it ,but Idle has written this to do it; https://www.purebasic.fr/english/viewtopic.php?p=633581
Re: c header files
+1
PB would become extremely powerful.
So easy access to C libs would be awesome.
PB would become extremely powerful.
So easy access to C libs would be awesome.
Re: c header files
Currently the problem is if you !#include file.h; it gets added to the main function output in the generated c and you don't want it there as it will try to compile it rather than just adding the symbols.
The solution is easy enough but we need the c headers of the gcc tool chain used added to the SDK directory
Add a copy of the c system headers to the sdk directory
Tell the gcc compiler where to find the c system headers on the command line "-I path_to_c_includes"
when the compiler sees !#include somlib.h in your code it deletes it and adds it to the command line "-include path_to_somelib.h"
or add it to a pboutput.h then, include pboutput.c in the .h at the end of the parse and pass the .h to the gcc compiler probably simpler
Then we have access to the c lib with inline c and it's easy enough to wrap in PB functions or macros.
Automatically Importing c headers to PB is actually far from trivial. I tried c-tags, u-tags and castXML which is the most promising of them but it's a whole llvm tool chain and it generates an XML tree that's still difficult to parse but it has most of the info that's needed to output a PB Include file, the rest of the info can be queried from the gcc compiler.
The solution is easy enough but we need the c headers of the gcc tool chain used added to the SDK directory
Add a copy of the c system headers to the sdk directory
Tell the gcc compiler where to find the c system headers on the command line "-I path_to_c_includes"
when the compiler sees !#include somlib.h in your code it deletes it and adds it to the command line "-include path_to_somelib.h"
or add it to a pboutput.h then, include pboutput.c in the .h at the end of the parse and pass the .h to the gcc compiler probably simpler
Then we have access to the c lib with inline c and it's easy enough to wrap in PB functions or macros.
Automatically Importing c headers to PB is actually far from trivial. I tried c-tags, u-tags and castXML which is the most promising of them but it's a whole llvm tool chain and it generates an XML tree that's still difficult to parse but it has most of the info that's needed to output a PB Include file, the rest of the info can be queried from the gcc compiler.