[fpc-pascal] FPC on ARM (eg Zaurus)

Den Jean geeken at pandora.be
Mon Nov 22 23:30:32 CET 2004


On Sunday 21 November 2004 11:41 pm, Den Jean wrote:
> I also debugged it on the zaurus with gdb.
> 


I debugged somewhat more and this learned me that the record Method 
is passed by reference instead of by value as it should.
With a little hack I managed to force a call by value.


Library extract that shows the function that expects a record by value.
--------------------------------------------------------------------------------------------------------------
   // C definition in library of function that expects a record of type TMethod by value (hook parameter)
   C_EXPORT void QButton_hook_hook_clicked(QButton_hookH handle, QHookH hook);

  // definition of QHookH in library
  typedef struct {
    void *func;
    void *data;
  } QHook;
  typedef QHook QHookH;
--------------------------------------------------------------------------------------------------------------



Here is the Pascal code that passed the record by reference instead of by value
--------------------------------------------------------------------------------------------------------------
  // Pascal definition of external library function
  QHookH = TMethod;
  procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;
  procedure QButton_hook_hook_clicked; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';
  
  // pascal code that calls the library function and passes the record by reference instead of by value
  QButton_hook_hook_clicked(button_hook,Method);
--------------------------------------------------------------------------------------------------------------



Here is the hack that enables me to force passing by value (the program than works)
--------------------------------------------------------------------------------------------------------------
  procedure QButton_hook_hook_clicked2(handle: QButton_hookH; func: integer; data: integer); cdecl;
  procedure QButton_hook_hook_clicked2; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';

  // this call works
  QButton_hook_hook_clicked2(button_hook,integer(Method.code),integer(Method.data));
--------------------------------------------------------------------------------------------------------------



I hope this helps in fixing the arm-port. :-)

kind regards,

Jan




More information about the fpc-pascal mailing list