One of the hardest things to do when writing an application with multiple languages and tools is to create and maintain interfaces to the definition file. Luckily, C++builder has done all this for you. When adding one to a project. Pas file, C++builder automatically creates a. hpp file.
In the CPP file, you can invoke Pascal's functions, objects, and so on. This provides a convenient way for the programmers of Delphi to transplant all or part of the project.
The following is the principle of using Delphi code in C++builder:
1. In the C++builder form editor, you cannot modify or edit the Delphi form. However, you can modify the Pas file and child nodes of the Delphi form. You can use the Convert program in the bin directory to convert the Delphi form to text format, then edit the Delphi form as text, and then convert it back to the DFM file format. The key is to keep in mind that you can edit Delphi's pas file in the IDE, but you can't edit Delphi's form file (DFM file).
2, in the same file, C + + and Object Pascal can not be positioned simultaneously. Object Pascal can be called by C + + and vice versa. But in C + +, calling Pascal is easier than calling C + + from Pascal.
3, C++builder Project can not link DCU file, but can directly use the source code. Another way to do this is to make an obj file that can be c++builder linked (if you are using delphi3.x). This approach adapts to forms, components, and cells.
C++builder doesn't care if the unit in the project is written in C + + or Delphi. C + + Builder will be compiled as C++builder unified.
In general, any unit that can be compiled with the Delphi compiler in delphi3.x
Can be compiled in C++builder. C++builder can compile the following:
1, Delphi form;
2, containing the object of the Delphi unit;
3, including processes, functions, constants, arrays, such as the Delphi Unit;
4, Delphi components.
In the C++builder project, the steps to add the Delphi unit are as follows:
1. Choose Projet| Add to Project
2. Select CPP, C, PAS, RES, lib, or obj from the Add to Project dialog box. For the Delphi unit, select Pas.
3, browse the directory and select the documents required to join the project.
4, after you find the required files, click Open to complete. Pascal files need not be further processed in any way.
Using the Delphi component in C++builder
It is easy to use the Delphi component in C++builder. Most components can be used directly without modification, but sometimes the compilation errors that occur when the component palette is installed can cause problems with Delphi components.
When trying to use the Delphi component in C++builder, you may experience problems such as link errors.
There are three file extensions in C++builder for components, obj, CPP, pas files, and c++builder have different processing methods for each file extension.
1, use. Obj file to install the component, the compiler links the target file to the package library.
2, if it is. CPP file, you first invoke the C + + compiler to produce a. Obj file, and then link to the component library.
3, if it is. Pas file, the Pascal compiler is called first, and the compiler
is a small compiler. It is different from the Pascal compiler in Delphi. It not only creates a Delphi Compiled Units (DCU) file, but also produces one. obj file and a C + + header file with a. hpp extension (when using Pascal files, you can force the production of C + + header files, obj, and DCU files.) The command line state is used. JPHN as an optional parameter for DCC32.exe). And then. The obj file is linked to the component library, and the header file is used for the description of the class for the application.
Although you create a header file for C + +, problems can sometimes occur. Some Pascal-language features cannot be converted into
C + +, and thus may cause problems in the following three areas.
1, to the component library installation components;
2, in the C++builder generation of C + + header files;
3, the use of Delphi components after the link C++builder application.
You can use the code of Object Pascal in C++builder, which is an outrageous stunt. The entire VCL is written in Object Pascal and can be linked to C++builder code. Remember, however, that not all links are possible because of the very few incompatibilities between C + + and Object Pascal.