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. 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 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.
Unfortunately, the positioning of comments is generally a difficult problem because code parsers usually ignore them. The subsequent insertion of comments occurs outside of certain parsed units and therefore sometimes not exactly in the expected places. The user may have to experiment a bit here. |
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |