Predefined identifier Cpp

Top  Previous  Next

Pretranslated C++ code > Preparing Delphi code > Predefined identifier Cpp

 

In the professional version of Delphi2Cpp the identifier Cpp is pre-defined in the translator. The preprocessor interprets code areas, in which a test for the definition of Cpp succeeds, a special way: they are enclosed in the special brackets  (*_ ... _*) so that the translator then writes these text areas unchanged into the C++ code.

 

For example:

 

{$ifdef Cpp}

  out << s << endl;

{$else}

  WriteLn(s); 

{$endif}

 

After pre-processing the translator gets:

 

(*_ out << s << endl; _*)

 

and because of the special treatment of the brackets (*_..._*), the final C++ output is:

 

out << s << endl;

 

Delphi2Cpp ignores the part of code in the {$else}-section completely, but it is visible to the Delphi compiler. So, this special way of the conditional compilation makes it possible that both the original Delphi code and the generated C++ code remain compiling.

 

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content