| 
       Conditional compilation  | 
    Top Previous Next | 
| 
 User interface > Translation > Preprocessing > Conditional compilation 
 Delphi2C# uses a preprocessor (pre-translator), which prepares the source text so that directives for the conditional compilation are evaluated and removed. However, unlike in Delphi conditional compilation, the Delphi2C# pre-processor only can evaluate conditional symbols, but usually cannot evaluate constants in the Delphi language and such constants never can be set by conditional compilation. 
 For example, conditional expressions like 
 {$IF CompilerVersion >= 17.0} 
 
 are evaluated, but integer values are evaluated and only operators, which also exist in C#. Sizeof-expressions like tho following are evaluated too 
 {$IF SizeOf(Extended) >= 10} {$DEFINE EXTENDEDHAS10BYTES} {$ENDIF} 
 as long, as the size can be taken from the type-map. In System pas the is the following code: 
 {$IF SizeOf(Extended) <> SizeOf(TExtended80Rec)} {$MESSAGE ERROR 'TExtended80Rec has incorrect size'} {$ENDIF } 
 "TExtended80Rec" is not defined in the type-map and therefore Delphi2Cpp cannot evaluate the expression. 
 If there is an expression, which cannot be evaluated, a warning is written into the code: 
 // pre-processor can't evaluate ... 
 The source code has to be corrected by hand then. 
 
 The Delphi2C# pre-processor cannot set new Delphi constants as in the following code from the Jedi components in JvConsts.pas 
 const ... {$IFDEF DELPHI26} SDelphiKey = 'Software\Embarcadero\BDS\20.0'; {$ENDIF DELPHI26} 
 {$IF not declared(SDelphiKey)} {$MESSAGE FATAL 'Declaration for SDelphiKey is missing'} {$IFEND} 
 Even if DELPHI26 is set, SDelphiKey would not be declared. 
 
 Include directives are executed correctly. 
 {$I filename} {$INCLUDE filename} 
 The file filename is included into the source. 
 
 The definitions can be set in the options dialog. 
 
 
  | 
| 
       This page belongs to the Delphi2C# Documentation  | 
    Delphi2C# home Content |