[fpc-pascal] trying to use C code in .pas on WIN32

Sven Barth pascaldragon at googlemail.com
Thu Jan 31 23:52:33 CET 2019

Am Do., 31. Jan. 2019, 22:03 hat Marc Santhoff <M.Santhoff at web.de>

> On Thu, 2019-01-31 at 11:00 -0700, conlin664 via fpc-pascal wrote:
> > sven,
> >
> > so I just tried, what I think you said:
> >
> > procedure HelloC; cdecl; external name 'HelloC';
> >
> > pcode.pas(19,1) Error: Undefined symbol: _HelloC
> >
> >
> > sorry for complaining about windows, but i feel like this is more
> difficult
> > on windows.
> > All of the FPC examples, seem to run without this extra '_' business and
> i
> > suspect they are on linux Os macOs.
> You could rename your "HelloC.o to "_HelloC.o" before archiving inte the
> library? Not that beautiful, but would be working, wouldn't it?

That is the object file, not the symbol. The symbol is the important part

> @Sven:
> Maybe it is a later addition,  but her on fpc 2.6.4 your syntax is not
> mentioned in the Programmers Guide (prog.pdf).
> If i did look carefully enough there is no description of the syntax for:
> "external name <NAME>"

It's an old syntax. Probably it was simply forgotten to be added to the
documentation. Happens... 🤷‍♀️

And more, those details of naming and the different name conventions on
> Win32
> and Win64 are missing, too. I think there should be at least a wiki page or
> better some explanations in the Programmers Guide.

This is part of the platform's ABI. It's not our job to document that, only
to make it usable.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190131/bc153fff/attachment.html>

More information about the fpc-pascal mailing list