[fpc-devel] Armel problems

Den Jean Den.Jean at telenet.be
Mon May 17 22:22:13 CEST 2010


Hi,

I am investigating why Qt on armel has problems.

I think that one of the problems is 
that when c-functions are called from 
pascal that the parameters are not passed 
correctly (or not as I expected and accommodated for).

I noticed that when the parameter is a 
"<procedure variable type of procedure of object;CDecl>"
like @MyMethod  (method of a class, with a cdecl decoration)
that the c-functions do not get the correct addresses.

When I change the pascal definition of the external c-function
and replace the "procedure () of object cdecl;" with
2 pointer parameters (MethodFunc,MethodData:Pointer) and
use (@TClass.MyMethod,Self) ... well then it works fine.

In the C-library I expect to receive a struct 
that I declared like this:
typedef struct {
  void *func;
  void *data;
} QHook;

Pascal:
type QAbstractButton_clicked2_Event = procedure () of object cdecl;
// when c-function declared like this
procedure QAbstractButton_hook_hook_clicked2(handle: QAbstractButton_hookH; hook: QAbstractButton_clicked2_Event); cdecl; external Qt4PasLib name 'QAbstractButton_hook_hook_clicked2';
// then this call does not work
QAbstractButton_hook_hook_clicked2(Hook, at MyMethod);

// when c-function declared like this
procedure testhook(handle: QAbstractButton_hookH; HookFunc,HookData:Pointer); cdecl; external Qt4PasLib name 'QAbstractButton_hook_hook_clicked2';
// then this works in constructor of TMyClass
testhook(Hook, at TMyClass.MyMethod,self)

fpc: latest svn, compiled with -dFPC_ARMEL
Code:{$mode objfpc}{$H+}

kind regards,

Den Jean



More information about the fpc-devel mailing list