curl-library
Re: examples compiler warnings
Date: Fri, 23 Sep 2011 12:51:35 +0100
Well, that would "fix" the diagnostic, but I wonder how gcc might
react to a conditional format. However, if I were to look at such a
doctored sample as a sample of doing a particular library function,
this macro would get in the way and might make me conclude that this
library isn't quite what I am looking for.
If the difference between the compilers is that much, I'd vote for
separate unix and windows samples. Presumably the windows folks want
the stuff in visual studio anyhow. And there are even some Linux folks
who swear by eclipse.
Why not ask for some sample zars put themselves forward?
It might even be possible to have a generic set of samples from which
one can mechanically generate samples that cope with the
idiosyncrasies of the various platforms. (E.g., generate the
appropriate %l or %d from %zd.)
On 23 September 2011 12:16, Yang Tse <yangsita_at_gmail.com> wrote:
> 2011/9/23 John P. Hartmann <jphartmann_at_gmail.com>:
>> Might you be overlooking that sizeof() is not a constant expression?
>>
>> You'd have to select the format at runtime?
>
> Yes at runtime.
>
> For these intended to be kept simple to compile/link examples, which
> have a single *.c source code file, it could be done for example using
> a header file that implemented a function that returns proper size_t
> print format and a macro definition which simply called the function.
>
> Later on in source file wanting to use it it, it is just a matter of
> including the header file and using the macro as format specifier.
>
> --
> -=[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