[Lazarus] Delphi-Lazarus compatible code including serial port?
Bo Berglund
bo.berglund at gmail.com
Sun Oct 10 17:47:48 CEST 2010
On Sun, 10 Oct 2010 12:03:42 +0200, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
>On Sun, 10 Oct 2010 11:46:43 +0200
>Bo Berglund <bo.berglund at gmail.com> wrote:
>
>> But how would this be done more specifically? Is there some
>> description available on making code compatible between Delphi and
>> Lazarus when there are component differences in the two systems as I
>> described above?
>
>There are many ways. For example:
>
>uses
> {$IFDEF LCL} // or use ifdef FPC
> fpcunit
> {$ELSE}
> delphiunit
> {$ENDIF};
>
>or you can put the whole unit into ifdefs:
>
>myserial.pas:
>
>{$IFDEF FPC}
>{$INCLUDE fpcserial.pas}
>{$ELSE}
>{$INCLUDE delphiserial.pas}
>{$ENDIF}
>
>
I am trying to make a wrapper for the sdpoSerial so it will mimick the
TSerial I am using in Delphi. With the conditionals in place Delphi
with use unit Serial and Lazarus unit SerialLazarus (the wrapper):
uses
{$IFDEF LCL} // or use ifdef FPC
SerialLazarus,
{$ELSE}
Serial,
{$ENDIF}
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?)
--
Bo Berglund
Developer in Sweden
More information about the Lazarus
mailing list