On 31 May 2009, at 15:28, Coco Pascal wrote:
Marco van de Voort schreef:
In our previous episode, Coco Pascal said:
I have a library with udf routines using the cdecl calling
convention, required by Firebird. This seems to work well on win32.
How exactly?
?
function Y_Odd(const AValue: Int64): LongInt; cdecl; export;
begin
if Odd(AValue) then
Result := -1
else
Result := 0;
end; {Y_Odd}
exports
Y_Odd;
This works fine with Firebird. If I declare the stdcall calling
convention Firebird can't find its entrypoint.
cdecl automatically enables C-compiler-compatible name mangling for
exported procedures. stdcall doesn't. So it's normal that Firebird
does not find the entrypoint when using stdcall, as it does not
support FPC-style name mangling.
There is no way to get C name mangling without the calling convention,
so you have to manually declare an alias in that case. E.g.,
function Y_Odd(const AValue: Int64): LongInt; cdecl; alias:
'_Y_Odd'; export;
Whether or not you need an extra underscore before the alias name
depends on the target platform. Win32 requires one.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal