Stdcall v. ccall on Windows FFI

Simon Marlow marlowsd at
Fri Jun 24 13:45:52 CEST 2011

On 22/06/2011 01:28, Mauricio CA wrote:
> Hi,
> Haskell FFI addendum, when talking about calling conventions, says
> that[1]:
>     ccall
>         Calling convention of the standard C compiler on a system
>     stdcall
>         Calling convention of the Win32 API (matches Pascal conventions)
> I wonder: what would correspond to such "standard C compiler" in
> Windows? Is it, say, Visual Studio? And which convention does it use
> by default?  Is it safe to assume that whatever is contained in a C file
> compiled inside a Cabal package in Windows will have a calling convention
> matched by 'ccall'?

I'd say that ccall is the calling convention that a C compiler on that 
platform will use unless you specify otherwise.  For example, on Windows 
you always have to specify __stdcall if you want it - the Win32 header 
files have it all over the place, and you can't call Win32 functions by 
defining their prototypes yourself unless you add __stdcall.

So the answer to your last question is "yes"


More information about the Libraries mailing list