[fpc-devel] Safecall on Linux (and other unices?)
Joost van der Sluis
joost at cnoc.nl
Wed Jul 21 11:28:55 CEST 2010
I've finally managed to get xpcom/gecko to work (partly) on linux/i386.
The delphi/fpc gecko-headers uses the safecall calling convention a
On Windows a safecall is in principle a stdcall with a 'hidden' function
result which contains a value (nsresult) to check if there was any
problem during the call of the procedure/function.
I had to find out what calling convention is used by xpcom on Linux. And
in fact it's quite logical: it uses cdecl. (As most c-libraries do, use
stdcall on Windows, cdecl on others)
So if we want to use xpcom on Linux the same way as on Windows we need a
special calling convention which hides the nsresult from the programmer
and is compatible with cdecl. We need to have a "cdecl+hidden exception
handling" calling convention.
At this moment the 'safecall' calling convention on Linux is undefined.
It does exist but has no real meaning. (In fact it is just stdcall, the
exception-handling code is only added on Windows by the compiler)
Is it an idea to change the 'safecall' convention on Linux/i386 to be
'cdecl + hidden exception handling' ?
That way we can use xpcom, which you could see as the cross-platform
com/activex system, on both Windows and Linux/Unix(?) with the same
code. And that's what safecall is for: too easy com/activex programming
More information about the fpc-devel