[fpc-pascal] trying to use C code in .pas on WIN32
Marc Santhoff
M.Santhoff at web.de
Fri Jan 25 00:55:49 CET 2019
On Wed, 2019-01-23 at 14:30 -0700, conlin664 via fpc-pascal wrote:
> I've done research, but am just missing something.
> my .pas code links just fine, but doesn't RUN.
> ( first writeln never appears )
> If I remove the external call to C code, then the writeln works as normal.
>
> Problem:
>
> I have c code, which I'm compiling on a WIN32 machine ( yes the horror )
> using GCC 4.5.2 target mingw32
>
> It generates .o files which i grouped together with ar into common.a
> I then renamed common.a to be libcommon.a
>
> Then I have a
>
> Common.pas file:
>
> unit Common;
> interface
>
> uses
> sysutils, dos, CTypes;
>
> {$linklib libcommon.a }
>
> procedure CutilInit; cdecl; external 'CutilInit';
>
> implementation
>
> end.
>
Try stdcall on Win32:
procedure CutilInit; stdcall; external 'common' name 'CutilInit';
If the full external declaration is necessary you'll have to try. I had to
when using a dynamic library (.dll in win32 terms).
--
Marc Santhoff <M.Santhoff at web.de>
More information about the fpc-pascal
mailing list