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.
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
Ross Paterson <ross@soi.city.ac.uk> 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 am not mistaken, we have had this discussion before. Unfortunately, haskell.org mailing list archives are not easy to search, so please excuse the lack of reference. In fact, the FFI used to have a default calling convention and we made a conscious decision against having a default. "Simon Marlow" <simonmar@microsoft.com> wrote,
So I'd say that specifying a "default" calling convention which maps to stdcall on Windows and ccall on Unix is probably a bad idea. You've just got to know which one to use on Windows - this is the job for a tool which checks the FFI decls against the prototypes.
IIRC, that was the gist of the argument last time. I propose to stick with this previous decision. Cheers, Manuel
participants (3)
-
Alastair Reid -
Manuel M T Chakravarty -
Ross Paterson