I'm working on a component that should be shared between Delphi and C++Builder, so I'm using Pascal as the lingua franca. Because I don't have Delphi on my computer at home, I first created the component in the Lazarus IDE. Now I "ported" it to Delphi and found an astonishing syntax problem:
This compiles with FPC (but not Delphi):
FSync.FSyncMethod := @SyncCheckInput;
This compiles with Delphi (but not FPC):
FSync.FSyncMethod := SyncCheckInput;
How can I share a unit between Lazarus and Delphi despite this syntactic divergence?
Insert this at the beginning of your units:
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
This will instruct FreePascal to use the Delphi dialect to compile the unit. Delphi will ignore the {$MODE DELPHI}
directive because FPC
is not defined.
You can then use this
FSync.FSyncMethod := SyncCheckInput;
for setting events dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With