[fpc-devel] Safecall on Linux (and other unices?)

Sven Barth pascaldragon at googlemail.com
Wed Jul 21 20:57:53 CEST 2010


Hi!

Am 21.07.2010 16:36, schrieb Hans-Peter Diettrich:
> José Mejuto schrieb:
>
>> It is not 100% cdecl, const records in safecall must be passed as
>> reference while in cdecl a copy of the record is being passed.
>
> Copies IMO make no sense here, when "const" protects the record elements
> from any modifications. That's why a compiler should be free to pass
> short consts by value, and larger ones (exceeding sizeof(pointer)) by
> reference.
>
> But of course the definition of the systemwide cdecl and safecall
> conventions must be observed. When no such definition exists for
> safecall on a platform, every compiler can define it differently,
> preventing the use of such procedures in external code (.so).

Well... for Linux exists no safecall convention and the only library 
that might profit from it is XPCOM which uses cdecl procedures that are 
compatible with the idea of safecall.
But if we implement safecall on Linux to be used with XPCOM then we 
can't simply define that const records are passed by reference, because 
the underlying/wrapped calling convention is still cdecl.
I myself think of safecall simply as some kind of "syntactic sugar" 
which makes using (XP)COM easier.

Regards,
Sven



More information about the fpc-devel mailing list