[fpc-pascal] library initialization and deinitialization
sethdgrover at gmail.com
Fri Jun 15 23:37:35 CEST 2007
I've got a shared library (.so) I wrote in C, with initialization and
finalization code declared by using the GCC attributes constructor and
destructor. These init and fini functions simply print out "start" and
"stop" to stdout. The .so exports one function, which prints out
I've got a test program (also written in C) which calls the .so's
function. What I see on stdout is
Just like you'd expect.
I wrote a Free Pascal test program which also uses the .so. However,
what I see is this:
So for some reason, the fini never seems to get called! I thought this
was strange, so I wrote a similar library in free pascal:
procedure SayHello (); cdecl; export;
Again, I ran a c test program against it and a fpc test program
against it. The C program's output was:
The freepascal program's output was:
What's going on here?
With humble thanks,
Who is John Galt?
More information about the fpc-pascal