[fpc-pascal] const records passed incorrectly
Eduardo Morras
emorras at xroff.net
Mon Nov 16 16:35:44 CET 2009
At 04:33 16/11/2009, you wrote:
>Hi all. I am new to fpc and linux in general, though I do have a long
>time experience with Delphi.
>
>I was writing some code basic system (using the libc library) when I
>ran across the following problem .. some code:
>
>const
> libc = 'libc.so.6';
>
>type
> TTimeSpec = record
> Sec: Cardinal; { Seconds }
> NSec: Cardinal; { Nanoseconds }
> end;
> PTimeSpec = ^TTimeSpec;
>
>function nanosleep(const RequestedTime: TTimeSpec; Remaining:
>PTimeSpec): Integer; cdecl; external libc;
>
>The problem with fpc and the above import is with the RequestedTime
>parameter, declared as a const record. In Delphi declaring a const
>record parameter cause the compiler to generate code to pass the
>record by reference (that is to say passing the address). In fpc,
>however this is not happening.
>
>My question is why. Why isn't fpc generating the code to pass a const
>record as a reference?
>
>I can find tons of WinAPI code where records are passed as const
>references by Delphi. I see this issue causing me some headaches as I
>port my Delphi code to run across platforms using fpc.
One question, why do you reimplement libc<->fpc wrapping lib? This function is in the BaseUnix unit as fpnanosleep.
HTH
----------------------------------------------
Useful Acronyms: GPL = Greedy Pengüin Licence
More information about the fpc-pascal
mailing list