[Lazarus] Delphi-Lazarus compatible code including serial port?

Sven Barth pascaldragon at googlemail.com
Sun Oct 10 17:52:46 CEST 2010


On 10.10.2010 17:47, Bo Berglund wrote:
> One question though:
> I need to enter this at the top of my big unit to stop Lazarus/FPC
> from complaining about syntax errors:
>
> {$MODE Delphi}
>
> But if this is detected by Delphi it will complain that there is no
> MODE command, so can I legally do this:
> {$IFDEF FPC}
> {$MODE Delphi}
> {$ENDIF}
>
> (I.e. can one enter compiler directives condistioned on other things
> in an ifdef construct?)
>
>

Yes, that is perfectly legal and even necessary if you use multiple 
compilers.
You can also write all those settings into an *.inc file and just 
include that at the top of your unit (e.g. {$I compilerswitches.inc}); 
this works in both FPC and Delphi and so you have the same settings in 
all your units where you include that file (of course you need to 
include the {$ifdef fpc} inside the include file).

Regards,
Sven




More information about the Lazarus mailing list