[fpc-pascal] Executing python code from a pascal program

Adrian Maier adrian.maier at gmail.com
Tue Nov 14 08:14:53 CET 2006


On 11/13/06, Leonardo M. Ramé <martinrame at yahoo.com> wrote:
> I created a Python.pas unit this way using Delphi and it works correctly (note the cdecl directive
> before external):
>
> unit python;
>
> interface
>   procedure Py_Initialize; cdecl; external 'python24.dll';
>   procedure Py_Finalize; cdecl; external 'python24.dll';
>   function PyRun_SimpleString(_para1:Pchar):longint; cdecl; external 'python24.dll';
>
> implementation
> end.

Thanks Leonardo !

The trick was to add cdecl _before_  external  :

function PyRun_SimpleString(_para1:Pchar):longint; cdecl; external
name 'PyRun_SimpleString';

I had initially added cdecl _after_ the 'external' clause , but this
generated an
error ( directive CDECL has conflicts with other directives )  which confused
me into thinking that cdecl was not needed.


Thanks,
Adrian Maier



More information about the fpc-pascal mailing list