On Fri, 23 Apr 2004, Ivan Boldyrev wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 8720 day of my life Eric Marsden wrote:
> >>>>>> "ib" == Ivan Boldyrev <[EMAIL PROTECTED]> writes:
> >
> > ib> I'd like call C function with variable number of arguments (like
> > ib> printf or scanf) from CMU CL. I guess, I can't do it with UFFI.
> > ib> But I can't understand from docs how I can call it with CMU CL
> > ib> Alien facility.
> >
> > you can't. Making calls to vararg functions is platform-dependent, and
> > CMUCL doesn't have the necessary glue to enable it (though it probably
> > works "by accident" on current platforms if you use EXTERN-ALIEN and
> > declare the actual types passed).
>
> Every C call just push arguments on stack, doesn't it? Or compiler
> must exactly know which function is vararg and which is not?
Generally yes, it must also know types of arguments or, from the Lisp
side, one must push oneself correct arguments on stack. This is easy with
"typical" arguments, like int or pointer. Conventions vary for char etc.
I once needed varying arguments in MzScheme, so I made a small
routine in assembler, which took C function and list of arguments (FFI
worked that way), pushed arguments on stack and called C function.
However, arguments could only be strings or integers and had to be
always terminated by NULL.
This strategy could possibly work also for CMUCL, but is not general.
Zbyszek Jurkiewicz