Predefined identifier Cpp

Top  Previous  Next

Pretranslated C++ code > Preparing Delphi code > Frequent re-translation > Predefined identifier Cpp

 

In addition the the definitions which the user can set in the translation options the identifier CPP always is defined in Delphi2Cpp II. The pre-processor treats this identifier in a special manner. The pre-processor not simply writes the according code into the pre-processed code, but it puts it into the special brackets (*#_ ... _#*). In a second step the translator then removes the brackets.

 

For example:

 

{$ifdef CPP}

  out << s << endl;

{$else}

  WriteLn(s); 

{$endif}

 

The pre-processed code then is:

 

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

 

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

 

out << s << endl;

 

Delphi2Cpp II 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.

 

The identifiers in these section either can be normalized or can be left untouched. This is controlled by the CPP unification option.

 

 



This page belongs to the DelphiXE2Cpp11 Documentation

DelphiXE2Cpp11 home  Content