Writing Externals in Pascal?
Peter W A Wood
peterwawood at gmail.com
Mon Jul 5 19:59:11 EDT 2010
Hi Scott
I am also be interested in being able to develop externals in Free Pascal. At the moment, I am testing calling a dynamic load library written in Free Pascal from Rebol (a language written in C) using C calling conventions.
> It is impossible to get the level
> of granularity of compiler options with Borland's compilers
> (C++ Builder, Delphi) to get the combination of:
> 1. no leading underscore
You get to name the function in FPC. Here is an extract from my dll:
{$ifndef Darwin}
exports
version name 'version';
{$else}
exports
version name '_version';
{$endif}
> 2. mixed case exported symbols
I tested with a mixed case function name:
exports
accountingformat name '_accountingFormat',
version name '_version';
> 3. C-style parameter passing (first to last)
> 4- C-style stack frames (calling program cleans up
> the stack)
FPC includes a modifier for the cdecl calling convention (which I believe answers 3 & 4). Here is an example:
procedure version(var answer: shortstring);cdecl;
begin
answer := CurrentVersion;
end;
Regards
Peter Wood
More information about the use-livecode
mailing list