Re: stdcall

Alastair Reid <[email protected]>
Newsgroups gmane.comp.lang.haskell.ffi
Organization Reid Consulting (UK) Ltd
Message-ID <[email protected]>
On Saturday 19 July 2003 12:51 am, Ross Paterson wrote:
> Could the meaning of stdcall be broadened to "the standard calling
> convention for libraries on the native system", i.e. pascal on Win32
> (as now) and ccall on Unix?  It would save a lot of fuss for interfaces
> to portable libraries.

If I understand you correctly:

1) Even on Win32, a function defined with type:

    rty foo(argtys)

   should be called using stdcall.

2) But, most functions in Win32.h and friends are declared something like:

   pascal rty foo(argtys);

3) On Win32, the pascal qualifier is included not just on Win32-specific 
functions but also to functions available on other platforms (but without the 
pascal qualifier): ansi functions, opengl functions, etc.

If that is so, I think we want to have two separate kinds of calling 
convention.  I'll number the calling conventions to avoid getting into 
discussion about what to call them too early.

calling convention 1:  call using the C calling convention.  That is, use this 
calling convention if a function is declared:

   rty foo(argtys)

This is useful when the user (or his ffi preprocessor) wrote foo themselves.


calling convention 2: call using the dominant calling convention on that 
platform: pascal on windows, C on unix.


Possible names for these are:

convention 1: ccall or C
convention 2: stdcall 

I would make convention 1 be the default if none is specified or have no 
default.

A
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.