This function is writen in C with a variable number of arguments, that likes
"printf".
How do I declare this function in Object Pascal?
Thanks
GetDelimToken( [.....] );
With "array of const". Look up "Variant open array parameters" in the Delphi
help.
Cheers,
Ignacio
Array of const is the Delphi way of passing a variable number
of arguments to a function, but it is not compatible with C.
If you want to import a function from a DLL written in C
which has a variable number of arguments, use the varargs directive
(in Delphi 6 at least, not surre abt previous versions).
Look it up in the help.
Cheers,
Chris
Depends on your Delphi version. Since D6 you can use the varargs directive:
function printf(Format: PChar): Integer; cdecl; varargs;
external 'foo.dll';
With this declaration the compiler allows you to call this function with
additional parameters. Varargs *only* works for cdecl functions and only for
external declarations, if the help can be trusted. The compiler accepts a function
pointer declaration like
Var
printf: function (Format: PChar): Integer cdecl varargs;
though, so dynamic loading should also work.
Note that all the advice on using an open array parameter you have received in
the other replies is off target if your aim is to call an existing C function in a
DLL.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
I'm trying to embed Python in my delphi application.
I have known that an open array parameter function is not compatible with C,
and known why a "cdecl" caller push parameters from right to left
to make the format string of "printf" at the top of the stack
to let "printf" process variant parameters.
But I haven't known the "varargs" directive. Very Thanks.
Why Borland does not mention it in "what's new" secion of the online help?
"Peter Below (TeamB)" <10011...@compuXXserve.com>
VA.0000a25...@nomail.please...
No idea, i suppose it just fell through the cracks <g>.
http://membres.lycos.fr/marat/delphi/python.htm
Cheers,
Ignacio
--
No, don't send me e-mail directly. No, just don't.