[fpc-pascal] const records passed incorrectly
Anthony Walter
sysrpl at gmail.com
Mon Nov 16 04:33:34 CET 2009
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.
More information about the fpc-pascal
mailing list