curl-library
Re: libcurl using stdcall on windows
Date: Thu, 24 Feb 2005 20:31:06 +0100
I think (in curl.h header), the next code:
#if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB)
#if defined(BUILDING_LIBCURL)
#define CURL_EXTERN __declspec(dllexport)
#else
#define CURL_EXTERN __declspec(dllimport)
#endif
#else
#define CURL_EXTERN
#endif
Could be (only as an example):
#ifndef CURL_CALL
#define CURL_CALL
#endif
#if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB)
#if defined(BUILDING_LIBCURL)
#define CURL_EXTERN __declspec(dllexport) CURL_CALL
#else
#define CURL_EXTERN __declspec(dllimport) CURL_CALL
#endif
#else
#define CURL_EXTERN CURL_CALL
#endif
In the .h only have to add CURL_CALL to the function pointers typedefs.
And tomorrow, I'll think how to modify the makefile with another parameter.
Gonzalo Diethelm writes:
> Suggestion: use a pre-processor macro that:
>
> * expands to nothing on non-Windows platforms
> * expands to cdecl on Windows by default
> * can be redefined by the user to be something else (stdcall) at compile
> time
>
> Regards,
>
>
> --
> Gonzalo Diethelm
> gonzalo.diethelm_at_aditiva.com
>
>
>> -----Original Message-----
>> From: curl-library-bounces_at_cool.haxx.se
>> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Jeff Phillips
>> Sent: Thursday 24 February 2005 15:40
>> To: CL; Jeff Phillips
>> Cc: libcurl development
>> Subject: Re: libcurl using stdcall on windows
>>
>>
>> Hello Calu,
>>
>> I don't know if the libcurl team will want to put more
>> Windows-specific conditional code into the header files.
>>
>> For my part, I tend to build my C/C++ apps and DLLs
>> with __cdecl (/Gd) and explicitly place __stdcall on
>> those functions that require that convention, such as
>> those that I might want to export to VB.
>>
>> Take care,
>> Jeff
>>
>> --- CL <jscript_at_gmail.com> wrote:
>>
>> > Thanks for the feedback. That certainly led me back
>> > on track again.
>> > In addition to adding __cdecl to the callback
>> > function, I also
>> > explictly placed __cdecl on all functions that I
>> > called in
>> > <libCurl.h>. Considering that libCurl always uses
>> > __cdecl calling
>> > convention, should this change be included in the
>> > latest CVS version
>> > so that others building Win32 applications with
>> > __stdcall doesn't run
>> > into the same problem?
>> >
>> > Calu
>> >
>> >
>> >
>> > On Thu, 24 Feb 2005 08:07:52 -0800 (PST), Jeff
>> > Phillips <jeff_at_jeffp.net> wrote:
>> > > Hello CL,
>> > >
>> > > I don't recommending building libcurl with the
>> > stdcall
>> > > convention, because you won't be able to invoke
>> > > libcurl's vararg functions (like dfprintf_format
>> > and
>> > > curl_formadd) if you do this.
>> > >
>> > > That said, when you rebuild libcurl as cdecl, the
>> > > trick will be to ensure that the various libcurl
>> > > callbacks in your application are declared as
>> > cdecl
>> > > rather than stdcall, because libcurl, when
>> > compiled as
>> > > cdecl, will expect to clean the stack after
>> > invoking a
>> > > callback. So here's an example:
>> > >
>> > > size_t __cdecl write_function(char* szptr,
>> > > size_t sz, size_t nmemb, void* pvData)
>> > > {
>> > > return sz * nmemb; // for now
>> > > }
>> > >
>> > > Set up this callback with:
>> > >
>> > > curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION,
>> > > write_function);
>> > >
>> > > Hope this helps,
>> > > Jeff
>> > >
>> > > --- CL <jscript_at_gmail.com> wrote:
>> > >
>> > > > I'm trying to add libcurl to an existing windows
>> application that
>> > > > must uses stdcall calling convention. I've added /Gz
>> > > > (stdcall rather than
>> > > > cdecl ) to CCDEBUG and CCNODBG in makefile.vc6.
>> > Most
>> > > > of the souce code
>> > > > compiled without warning/errors after adding
>> > this
>> > > > flag. I'm only
>> > > > getting 4 errors that complains pretty much on
>> > the
>> > > > same problem:
>> > > >
>> > > > error C2152: 'function' : pointers to functions
>> > with
>> > > > different attributes
>> > > > warning C4024: 'dprintf_formatf' : different
>> > types
>> > > > for formal and
>> > > > actual parameter 2
>> > > > error C2152: 'function' : pointers to functions
>> > with
>> > > > different attributes
>> > > > warning C4024: 'dprintf_formatf' : different
>> > types
>> > > > for formal and
>> > > > actual parameter 2
>> > > > error C2152: 'function' : pointers to functions
>> > with
>> > > > different attributes
>> > > > warning C4024: 'dprintf_formatf' : different
>> > types
>> > > > for formal and
>> > > > actual parameter 2
>> > > > error C2152: 'function' : pointers to functions
>> > with
>> > > > different attributes
>> > > > warning C4024: 'dprintf_formatf' : different
>> > types
>> > > > for formal and
>> > > > actual parameter 2
>> > > >
>> > > > I'm pretty new to libcurl, and it took nearly
>> > the
>> > > > whole day yesterday
>> > > > for me to figure out the 'unresolved external
>> > symbol
>> > > > __imp__curl*'
>> > > > errors was related to this mix use of calling conventions. I
>> > > > appreciate if anyone can point me in the right
>> > > > direction in either:
>> > > > 1. how to mix cdecl and stdcall in the same
>> > > > application
>> > > > 2. what type of changes do I have to make to fix
>> > > > those errors listed here
>> > > >
>> > > > TIA
>> > > >
>> > > > calu
>> > > >
>> > >
>> > >
>> >
>>
>>
>>
>
Samuel Díaz García
Director Gerente
ArcosCom Wireless, S.L.L.
mailto:samueldg_at_arcoscom.com
http://www.arcoscom.com
móvil: 651 93 72 48
tlfn.: 956 70 13 15
fax: 956 70 34 83
Received on 2005-02-24