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

José Mejuto joshyfun at gmail.com
Thu Jul 22 19:05:10 CEST 2010

Hello Joost,

Thursday, July 22, 2010, 5:57:27 PM, you wrote:

>> Even if declarations in the code are wrong (which I had not checked, I
>> assumed they were fine) the "const" behavior with record in Windows
>> safecall and linux cdecl is different. 
JvdS> Offcourse the behaviour is different for a different calling convention
JvdS> and OS. That's perfectly normal. If all calling conventions were the
JvdS> same, we woudn't have them.

Yes, but I think, maybe I'm wrong, that a cdecl declaration in any
platform matches the same behavior in other platform. This means that:

procedure (a: pointer); cdecl;

is expected to produce the same effect (not internal implementation)
in any platform. So:

procedure (const a: record); safecall;

in Unix will produce a copy of "a" and in Windows a reference to "a"
which is not very portability friendly.

Anyway I think the problem is on the XPCOM guys, as they decide to
"define" safecall with different meanings in different platforms, so
in Windows it is "stdcall safecall" and in Unix "cdecl safecall"
(safecall referenced to the postprocessing of nsResult).

To me it smells like everything was designed in Linux and later they
decide to mimic the Windows Activex in the windows world.

Anyway whichever you decide is OK to me.

Best regards,

More information about the fpc-devel mailing list