cURL / Mailing Lists / curl-library / Single Mail

curl-library

Calling convention

From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Thu, 01 Nov 2007 16:03:18 +0100

Ops, wrong ML. Resending.
------------

As it is now all applications using libcurl (either dynamically or
the static lib) must be built with the same calling convention as
libcurl was built with. Normally this would be 'cdecl' (which is
implicit and the only (?) possible calling-convention in gcc).

Sometimes mixing e.g. 'fastcall', 'stdcall' and 'cdecl' would be
useful. I guess this would be an issue only on Windows and DOS
using non-gcc compilers.

But this would mean we should declare the calling-convention on
all public libcurl functions and function-pointer types.
E.g. in <curl/curl.h>:

#if !defined(CURL_CCONV)
#if (defined(__WATCOMC__) || defined(_MSC_VER))
#define CURL_CCONV __fastcall /* or __cdecl */
#else
#define CURL_CCONV
#endif
#endif
...
typedef int (*CURL_CCONV curl_sockopt_callback)(void *clientp,
                                                        curl_socket_t curlfd,
                                                        curlsocktype purpose);
...
CURL_EXTERN CURLcode CURL_CCONV curl_global_init(long flags);
...

Should we proceed with this idea? Any comments on the pros and cons.

--gv
Received on 2007-11-01