How to start

Top  Previous  Next

 

You will get good C++ translations of your Delphi code only, if you make the correct settings in dialog for the translation options, which can be shown by the button  OptionsProject . There are two main decisions to make.

 

 

1. C++ Builder or other compiler

 

 

The translation result depends on the C++ compiler you use. The main difference is between the C++Builder and all other compilers. C++-Builder has it's own C++ version of the Delphi RTL/VCL and Delphi2Cpp tries to optimize the translated code to work together with these libraries. So, depending on the used compiler the desired string type also has to be be chosen. C++ Builder has classes for AnsiStrings and WideStrings, which are very similar to the original Delphi types. For other compilers it is recommended to use std::string and std::wstring instead, if you don't want to write your own Delphi like string classes.

 

 

2. Choosing the correct source for the RTL/VCL:

 

 

Delphi2Cpp has to know the types and signatures of procedures and  functions in your Delphi source code to make a correct translation. That's no problem as far as these information stems from your own source code. You simply have to set the paths to your source code at the in the options dialog.

But all Delphi code implicitly also includes the System unit and most Delphi code uses at least the Sysutils unit too. Already translated C++ code for these both units is part of the Delphi2Cpp installation. In the same folder there are pas-files with the Delphi interface parts of these units. If no other units from the Delphi RTL/VCL are used in your code, you will get the best translation results, if you select the path to these pas-files as search path for the files not to convert.

Mostly your code will depend on more units of the Delphi RTL/VCL. If you are using Delphi2Cpp for the first time and you are curious to get some first results, you may select the paths to the original Delphi RTL/VCL as search path for the files not to convert. But unfortunately the original Delphi source code.has bugs and in longer term it is recommended, that you prepare a copy of Embarcadero's code.

 

If you make use of the original Delphi RTL/VCL, you should use also an "extended System.pas". This file corrects and completes the original "System.pas".

 

 

3. Setting the correct definitions

 

 

If you have selected the search paths to the Delphi RTL/VCL, your code still might not be translated correctly, if you haven't set the necessary definitions.

As default MSWINDOWS is.defined. If that would not be the case, even the original Sysutils.pas cannot be parsed, because e.g. the following code, would not be valid:

 

function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle =

        {$IFDEF LINUX} tlbsLF {$ENDIF}

        {$IFDEF MSWINDOWS} tlbsCRLF {$ENDIF}): string;

 

 

 

4. Preparation of the RTL/VCL code

 

It might be necessary to define some substitutions of ampersand-expressions and unfortunately the RTL/VCL code has flaws, which have to be corrected, if it has to be used.

 

 

5. Creating a dummy application or make a complete translation

 

Normally a complete translation will be made. But if your code is incomplete, you might chose to create a dummy application at first.

 

 

6. Starting the translation

 

 

After you have set your translation options you can save them by the button ProjectSaveAs and open the first file to to translate with the button FileOpen.. The source file is shown in the left window of the user interface. You can start the translation with the button Arrow_r. As soon as it is finished the C++ header and the C++ source code are shown in the windows on the right side of the application. Also the content on the left side might have changed: now the preprocessed Delphi code is shown there. You can save the translated code by the button FileSaveAs.

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content