[fpc-pascal] Porting code from Windows D2007, missing Windows functions

Bo Berglund bo.berglund at gmail.com
Thu Jul 14 08:22:21 CEST 2016


On Thu, 14 Jul 2016 07:55:05 +0200, Sven Barth
<pascaldragon at googlemail.com> wrote:

>Am 14.07.2016 07:08 schrieb "Bo Berglund" <bo.berglund at gmail.com>:
>>
>> I am porting a Delphi2007 utility from Windows to Linux (Raspbian
>> Jessie). It uses a unit I have downloaded from the web, which was said
>> to support FreePascal too.
>>
>> But now I am getting a number of missing identifier errors as follows
>> Function calls:
>> - SetFilePointer
>> - GetFileTime
>> - FileTimeToLocalFileTime
>> - FileTimeToDosDateTime
>> - SetEndOfFile
>>
>> Constants:
>> - FILE_CURRENT
>> - INVALID_HANDLE_VALUE
>>
>> It seems like these are defined in Windows and now in FPC they are
>> elsewhere.
>
>Those functions and constants don't exist on non-Windows. Try to convert
>your code to one of the abstractions Free Pascal (and also Delphi)
>provides, e.g. FileOpen() and friends or TFileStream.
>
>> The uses clause of the unit has the following content:
>>
>> uses
>> {$ifdef MSWINDOWS}
>>   Windows,
>> {$else}
>>   LibC, <== Error here, not found
>>   Types,
>> {$endif}
>>   SysUtils;
>>
>> It could not find LibC and when I asked on the Lazarus list I got a
>> reply to try Unix and/or BaseUnix instead. But this does not work so I
>> guess these functions are in another FPC unit somewhere.
>>
>> What should I add to the uses clause in place of LibC to get it to
>> compile on Linux?
>
>The LibC unit only exists on i386-linux and only for compatibility for
>Kylix. Other than that you should consider that unit as deprecated and
>instead use units like Unix, BaseUnix or Linux, depending on what
>functionality you need.

OK,
that was bad news for me because I have included the unit (PasZip from
Synopse) in order to make possible for my application to write
zipfiles containing measurement result files. I had a Windows specific
dll earlier and wanted to switch to multi-platform by using a
non-operatingsystem dependent method. On Synopse's website they state
that their code is portable across operating systems and specifically
mention FPC. So I grabbed PasZip because it encapsulates the zipping
in one pas unit and an include file.

I do not see how I can dig down intp PasZip and correct it for
multi-platform use given my limited knowledge of the innards of
Delphi/FPC.

Anyway thanks for pointing this out so I don't waste time trying to
find a unit to use to solve the problem.

I have to contact Synopse, even though they seem not so responsive...


-- 
Bo Berglund
Developer in Sweden




More information about the fpc-pascal mailing list