Predefined identifier CSHARP

Top  Previous  Next

Pretranslated C# code > Preparing Delphi code > Frequent re-translation > Predefined identifier CSHARP

In addition the the definitions which the user can set in the translation options the identifier CSHARP always is defined in Delphi2C#. The preprocessor 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 CSHARP}

 return;

{$ELSE}

 Exit;

{$ENDIF}

 

The pre-processed code then is:

 

(*#_ return; _#*)

 

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

 

return;

 

Delphi2C# ignores the part of code in the {$else}-section completely, but it is visible to the Delphi compiler. So, this special manner 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 CSHARP unification option.

 

Warning:

 

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 Delphi2C# Documentation

Delphi2C# home  Content