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

Den Jean geeken at pandora.be
Sun Nov 21 05:53:10 CET 2004


On Wednesday 10 November 2004 02:45 am, Florian Klaempfl wrote:

> >>Before I can test it, I've to reinstall my Zaurus, when updating to 
> >>3.5.1, the installation got broken :/

I have prepared something to test.

I created a small C-program as a reference (that works)
and then a FPC program that has a problem (it crashes
when compiled for ARM but not when compiled for intel/qvfb)

The program is a minimal Qt program with only one button.
We want to connect a pascal procedure to that button.
The binding is for pascal so it provides hooks to connect pascal TMethods.

--------------------------------------------------------------------------------------------
// Pascal code that connects a method to the slot clicked()
QButton_clicked_Event(Method):=MyClass.AppQuit;
QButton_hook_hook_clicked(button_hook,Method);
--------------------------------------------------------------------------------------------

It is this code that does not work under arm,
when the Method is called (the button is clicked), 
the program crashes.

By the way (not related to the problem)
  I did not give the button any text, because
  for this I need to initialize the binding with 
  some external pascal code (see bindhelp),
  and this is not possible in the simple C program.

To show how the Pascal Method gets called in the binding
Here are some extracts of the binding.
The signal clicked() gets connected to a slot of the Qt binding

----------------------------------------------------------------------------------------------
// this is C++ code that implements QButton_hook_hook_clicked(button_hook,Method);
// Method is passed as parameter hook and stored in variable clicked_event

    void hook_clicked(QHook &hook) { 
      if ( !clicked_event.func )
        connect(handle, SIGNAL(clicked()), this, SLOT(clicked_hook()));
      clicked_event = hook;
      if ( !hook.func )
        disconnect(handle, SIGNAL(clicked()), this, SLOT(clicked_hook()));
...
...
// clicked_event is defined as this
QHook clicked_event; 
...
...
// QHook is defines as this
typedef struct {
  void *func;
  void *data;
} QHook;
typedef QHook QHookH;
...

In the slot handler it calls the pascal method.
----------------------------------------------------------------------------------------------
       void clicked_hook() {
      if ( clicked_event.func ) {
        typedef void (*func_type)(void *data);
	(*(func_type)clicked_event.func)(clicked_event.data);
      }private slots:
----------------------------------------------------------------------------------------------


I hope this is enough starting information for this bug of the fpc arm crosscompiler.
Ask anything you may feel helpfull to solve this.

The codes is here:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/test01.tar.gz


By the way (perhaps related), for the intel/qvfb I need to add unit CMem as the first unit
of the uses clause to make any FPC Qt program work. 

If I add CMem when compiling  for arm, the program does not want to start. 
it complains with :
-------------------------------------------------------------
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
 No Qt/Embedded server appears to be running. 
 If you want to run this program as a server,
 add the -qws command line option.
-------------------------------------------------------------


kind regards,

Den Jean




More information about the fpc-pascal mailing list