cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: examples compiler warnings

From: John P. Hartmann <jphartmann_at_gmail.com>
Date: Thu, 22 Sep 2011 23:33:34 +0100

Might you be overlooking that sizeof() is not a constant expression?

You'd have to select the format at runtime?

printf((4 == sizeof(size_t) ? "%d" : "%l"), size);

On 22 September 2011 22:50, Yang Tse <yangsita_at_gmail.com> wrote:
> 2011/9/22 Guenter <lists_at_gknw.net>:
>> What speaks against having a proper format define in curlbuild.h? configure
>> could easily detect sizeof(size_t) and set the format define correctly, or?
>
> When you #include <curl/curl.h> you already get following defines:
>
> CURL_SIZEOF_LONG
> CURL_SIZEOF_CURL_OFF_T
> CURL_FORMAT_CURL_OFF_T
> CURL_FORMAT_CURL_OFF_TU
>
> Proper format for size_t can be derived from that and a sizeof(size_t)
> check in whatever source needs it.
>
> sizeof(size_t) > CURL_SIZEOF_LONG -> use CURL_FORMAT_CURL_OFF_T
> otherwise
> use %ld
>
> If compiler warnings in examples aren't important, I suppose it
> doesn't even justify modification (addition) of external API symbols
> to curl.h via curlbuild.h
>
> --
> -=[Yang]=-
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-23