On 14-Mar-2002, Simon Marlow <[EMAIL PROTECTED]> wrote: > I can't remember whether this has come up before, but to my surprise > I've just discovered that FFI foreign import declarations don't contain > enough infomration to be able to determine the correct calling > convention for a given C function. > > Background: recently we "fixed" a bug in GHC's native code generator > which was exposed by the following declaration: > > foreign import ccall unsafe > snprintf :: CString -> CSize -> CString -> Float -> IO ()
I don't see how interfacing with a varargs function as if it had a fixed prototype can ever be completely portable. C permits the calling convention to be different for varargs functions, and sometimes this is indeed desirable for efficiency: varargs functions require caller-pops argument passing convention, but known-prototype functions can use a more efficient callee-pops convention. Some C compilers have taken advantage of this. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp. _______________________________________________ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi