Just noticed there is a 'varargs' modifier in the fp2.6.1.Follwoing the sample code in the ref.chm,I tested in the IDE:
Function PrintF1(fmt : pchar); cdecl; varargs;
external ’c’ name ’printf’;
PrintF1(’%d %d\n’,1,1);
Actually PrintF1 is a function other than a procedure,so maybe the proper on could be:
Function PrintF1(fmt : pchar):integer; cdecl; varargs;
external ’c’ name ’printf’;
Here is the complete program:
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
Function PrintF1(fmt : pchar):integer; cdecl; varargs;
external 'c' name 'printf';
begin
PrintF1('%d %d\n',1,1);
readln;
end.
It compiles,but when it tried to startup,System Error:
The program can't start because c.dll missing from your computer.Try reinstalling the program to fix the problem.
I don't think there is such a c.dll in the OS.(My OS is Win7).
So could anybody figure me out what the the problem here?
BTW.Can I omit the extern 'c ' name blabla and define my own variadic functions/procedures ?
Thanks for your help in advance.