curl-library
Re: libcurl using stdcall on windows
Date: Thu, 24 Feb 2005 08:07:52 -0800 (PST)
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
>
Received on 2005-02-24