Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-03

Re: CLX for FPC + Bug i386 cdecl

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Den Jean

Hi,

We are porting CLX to FPC. You can see a first snapshot here: http://sourceforge.net/project/screenshots.php?group_id=116605 The use of the BitBtn shows that we dealt with {$R QButtons.res}

The code will be available at:
http://sourceforge.net/projects/qtforfpc/

There is still alot of work to do, diffs are welcome. The FPC Wiki shows someone else is busy at it too, any cooperation would be great.
By the way thx for the many updates to the rtl,
it is much easier than back in July when I first tried this. Also thx for renaming rtlconst(s) just after I had already replaced it everywhere :-)

BTW, our aim is to be able to kinda just recompile Kylix programs if ever we encounter problems with dcc on newer distributions. Some programs that have some qt dependencies, just cannot be ported that easy to LCL (yet). New programs should ofcourse use the lazarus/LCL and profit of its nice form editor. We will try to convert the xfm files with lazres after some further study of the classes unit

i386 FPC CDecl Bug encountered:
=================
When using libqtintf we call c-code and get called by c-code. For eg c-code calls this function in BindHelp.pas

function GetPointsLength(const PA: TPointArray): Integer; cdecl; export;

But with FPC this call fails. The way 'const TPointArray' is passed on the stack seems not ABI correct. I am an ABI analphabet, but I guess the address of the points should be on EBP+8 so the following test program tests this. With Kylix (dcc) it works and with FPC it fails.

=====================================
== Output of both compilers == =====================================
dcc TestPointArray
writeln('end of program');

dcc -q TestPointArray ; ./TestPointArray
Borland Delphi for Linux Version 14.5
Copyright (c) 1983,2002 Borland Software Corporation 59 lines, 0.03 seconds, 137636 bytes code, 7204 bytes data. GetPointsLength 1:
Length:3
GetPointsLength 2:
Length:3

ppc386 -Sd -v0 TestPointArray.pas ; ./TestPointArray Free Pascal Compiler version 1.9.9 [2005/03/08] for i386 Copyright (c) 1993-2005 by Florian Klaempfl
GetPointsLength 1:
Length:3
GetPointsLength 2:
Oooops:ip
Length:3

=====================================
== Test Program: == =====================================
program TestPointArray;
{$H+}

uses
  Classes, SysUtils, Types;
type
  PPointArray = ^TPointArray;
  TPointArray = array of TPoint;
var
  Points     : TPointArray;
  p          : PPointArray;
  i          : integer;
function GetPointsLength1 (PA: pointer): Integer; cdecl;
begin
  asm
    mov EAX,[EBP+$08]
    mov i,eax
  end;
writeln('GetPointsLength 1:');
if i  integer (p) then writeln ('   Oooops:ip');
if integer(PA)  integer (p) then writeln ('   Oooops:PAp');
Result:=Length(TPointArray(PA));
writeln('   Length:',Result);
end;
{$IFDEF FPC}
{$asmmode intel}
{$ENDIF}
function GetPointsLength2 (const PA: TPointArray): Integer; cdecl;
begin
  asm
    mov EAX,[EBP+$08]
    mov i,eax
  end;
writeln('GetPointsLength 2:');
if i  integer (p) then writeln ('   Oooops:ip');
if integer(PA)  integer (p) then writeln ('   Oooops:PAp');
Result:=Length(PA);
writeln('   Length:',Result);
end;
begin
SetLength (Points, 3);
Points [0] := Point (1,2);
Points [1] := Point (3,4);
Points [2] := Point (5,6);
;
getPointsLength1(Points);
getPointsLength2(Points);
end.

===========================

kind regards,

Den Jean

Reply by email