Hi everybody,

I am trying to use a shared lib written in C in my FPC program. The lib creates a number of threads and requires callbacks into the main app. It can call the callback from any of the threads.

When I compile without stack checking everything (seems) to work fine but when stack checking is on I get stack error (error 202) on entry to the callback function. I can break on the callback's 'begin' and see valid values for all the function parameters but when I step into the function body it crashes.

I say 'seems' when not using stack checking because when the app becomes large I get a lot of strange problems which would probably be explained by stack problems.

The .h file:
typedef int (*VortexOnAcceptedConnection) (VortexConnection * connection, axlPointer data);

The pascal file:
type
     PVortexConnection = Pointer;
     TaxlPointer = Pointer;
TVortexOnAcceptedConnection = function (connection:PVortexConnection; data:TaxlPointer):longint;cdecl;

{This is the callback function called by the C library. It never gets called from the pascal code.} function on_accepted(connection: PVortexConnection; data: TaxlPointer): longint;cdecl;
begin
 Result := 1;
end;

I have tried all the function modifiers, they all give the same problem.
I run fpc 2.2.4 on Kubuntu 9.04.

I ran the C version of this test application using valgrind and it doesn't give a single problem.

Any ideas or opinions will be appreciated.

Wimpie
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to