stdcall

Alastair Reid alastair at reid-consulting-uk.ltd.uk
Sat Jul 19 06:55:05 EDT 2003


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






More information about the FFI mailing list