On Wed, 9 May 2012 15:34:19 -0700 (PDT)
Hi,
Post by Frank HrebabetzkyComponentPascal: How do I write an interface to a C function
with a variable number of arguments, e.g.
int printf (const char *format, ... );
(I have been searching for hours on the web, but without success.)
Don't know, honestly, but I personally doubt you can, or at least it
won't be portable. I think originally (before varargs) it all had to
be done in assembly. And ANSI C dictates you must always #include
<stdio.h> because it's permitted to change the calling convention for
that function. So that's a bit complicated.
There was a similar query on comp.lang.ada recently (Apr. 10 - May 3)
titled "Importing C function with variable argument list", so you
could read that, they know much more than I do, but even they seemed
pessimistic.
Thanks for your answer. I got a similar response via private email.
So I will continue as I have been doing until now: write small C
libraries which export the functions which I really need (e.g.
int printInt (const char *format, int n)) and which internally call
those variable argument functions.