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

conlin664 conlin664 at yahoo.com
Tue Feb 5 23:52:05 CET 2019


Marc,

Hmmm. Okay, I just switched it to be  stdcall
and had to slightly alter the name, but it compiled and ran.

So my example is now with "cpp" names, so my HelloC is now:

procedure HelloC; stdcall; external name '__Z6HelloCv';

vs

procedure HelloC; cdecl; external name '_Z6HelloCv';

both link and run.

lol - ok, this routine had no parameters.

So I just added one parameter and both stdcall and cdecl work with only the
name change..

even when i have the cpp routine allocate something on the stack.
So, I'm not sure who's cleaning up the stack: Caller or callee

Strange.

from the programing guide there should be a difference between
cdecl and stdcall

but then we have
"When linking with code blocks compiled with
standard C compilers (such as GCC), the cdecl modifier should be used so as
to indicate that the
external routine uses C type calling conventions."

so I'm going to stick with cdecl and for now it's working and will be more
compatible when I also use this code on MacOs

cheers

john




--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/



More information about the fpc-pascal mailing list