Since Chet uses an actual compiler, you will need to have a (minimal) C develop environment installed, as well as LLVM with Clang. Clang needs to be able to find the system headers for the development environment. These will usually be available if you have some version of Visual Studio with Visual C++ installed. The free (community) edition of Visual Studio suffices.
As said in the readme on Github, unlike some other header translators, Chet uses the Clang compiler to parse header files, resulting in more accurate translations that require fewer manual adjustments.
Please check out the awesome features Chet lists:
- Translates C data types such as structs, union, enums, typedefs, procedural types and opaque types.
- Translates C functions to Delphi procedures or functions.
- Tries to translate
#define
declarations to constants where possible. - Generates a single
.pas
file for an entire directory of.h
files. This reduces issues due to dependencies between header files. - Generates output for multiple platforms (Windows, macOS, Linux, iOS and Android) if desired.
- You can customize the Clang parsing process by supplying command line arguments to the compiler.
- You can customize the output of some conversion operations.
- Retains any Doxygen style documentation comments if desired, or converts them to XmlDoc comments or PasDoc comments.
- Provides a GUI for configuring the conversion process, and allows you to save the conversion settings to a
.chet
project file for reuse.
Although Chet has amazing features, there are some limitations that the user has to pay attention on:
- Chet only works with C header files, not with C++ header files.
- All non-inlined functions in the header files are translated and assumed to be available in the static or dynamic library for the project. This does not have to be the case. (Inlined functions are never translated since they are never available in the library.)
- Since Clang is used to parse the header files, this means that Clangs preprocessor is run as well to perform conditional parsing (guided by
#ifdef
directives). This is both good and bad. It is good because it improves conversion accuracy. But it can be bad because it uses the system that Chet runs on to determine some conditional paths. For example, because Chet runs on Windows, it will parse code in#ifdef _WIN32
sections but skip any code in sections for other platforms.
You can run Chet first to check for any errors related to missing dependencies. If you get any dependency errors when running the translator, then you can download the dependencies here:
- LLVM with Clang (Clang for Windows (64-bit) is recommended);
- Visual Studio IDE (the free Community edition suffices; be sure to install C++ support).
You can use the pre-compiled 64-bit Windows Chet application in the Bin directory.
If you want to compile Chet yourself, then you also need libclang for Delphi and make sure the Delphi IDE can find it (the Chet project will find it automatically if the Neslib.Clang directory is at the same level as the Chet directory).
Chet is licensed under the Simplified BSD License.
From the Github article we understand that Chet is pretty straightforward. In many cases, you only need to provide a directory with header files, the name of the output .pas
file and select “Run Header Translator (F9)”.
For more control over the conversion process, you can specify various options, described below. The screenshot from GitHub for the project is below:
This is for sure the best header files parser, so if you want to check it, go to the link below and download it:
https://github.com/neslib/Chet
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
It always amazed me that Embarcadero does not have something similar themselves. They provide C++ Builder, right? C++ Builder can use Delphi, but not the other way around. Puzzles me… Would vastly improve the Delphi eco-system too if it works very well. And by that the use cases for Delphi.
I have been waiting a couple of weeks to be able to answer this question publicly. Look at RAD Studio 11 – a lot of work on Delphi / C++ interoperability has been done which should solve almost all of the issues or restrictions people might have run into with previous versions. It’s available…now.. 🙂
Will RAD Studio 11 allow the conversion of C++ header files to Delphi