On Sat, 8 Jul 2023, Hairy Pixels via fpc-pascal wrote:
In fact I filed a bug today which was related. Notice how I didn't use cdecl in
the program but another user tried to compile and had problems with cdecl also.
https://gitlab.com/freepascal.org/fpc/source/-/issues/40342
<https://gitlab.com/freepascal.org/fpc/source/-/issues/40342#note_1462402401>
Basically this program:
{$mode objfpc}
program test;
function printf(format: PChar): Integer; external; cdecl; varargs;
You must put the cdecl (which is the calling convention) before the external:
{$linklib c}
function printf(format: PChar): Integer; cdecl; external; varargs;
begin
printf('%d is the answer'#10,42)
end.
Will work and will print
42 is the answer
Michael.
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal