cURL / Mailing Lists / curl-library / Single Mail


Re: Calling convention

From: Gisle Vanem <>
Date: Fri, 02 Nov 2007 14:51:00 +0100

"Brian Dessent" <> wrote:

> I don't know why you exclude gcc here, as it fully supports all of those
> calling conventions on Windows (i.e. Cygwin and MinGW.) In fact the
> entire Win32 API uses the stdcall calling convention

I know. What I meant to say was that gcc doesn't AFAIK have an option to
globally use e.g. 'stdcall' for every function (like cl /Gz does). One have to
specify "int __stdcall foo()" for every declaration.

> Frankly it sounds like a horrible idea. Library versioning is already
> tricky enough that I don't see why you'd want to intentionally muddy the
> waters further by making it easier to produce a DLL that's incompatible

My experience is that when the calling convention is specified, bugs originating
from wrong calling convention in e.g. function pointers are easier to detect.
If an application (linking to libcurl) is using "cl /Gr" (fastcall) globally and
is trying to set a libcurl callback which requires 'cdecl' convention (since libcurl
was built without "/Gr"), then the compiler would flag it as an *error* when trying
to convert from 'fastcall' to 'cdecl'. Defining the calling convention in <curl/curl.h>
avoids rebuilding everything (the application and libcurl) to use the same convention.
It set the ABI in stone, so to say.

Received on 2007-11-02