cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: s/bool/int

From: Tor Arntsen <tor_at_spacetec.no>
Date: Wed, 26 May 2010 12:39:50 +0200

On Wed, May 26, 2010 at 12:29, Kamil Dudka <kdudka_at_redhat.com> wrote:
> On Wed May 26 2010 12:20:36 Tor Arntsen wrote:
>> Then I suggest we change it to an enum, as mentioned in the latest
>> discussion between myself and Michael.
>
> On all platform I use libcurl, it already utilizes the standard bool, so it
> will not affect me directly.  I only want to keep the code itself as is, at
> least.  As for the enum idea, I like it.  I see gnulib's stdbool module is
> also based on enum:
>
> http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/stdbool.in.h
>
> Moreover we already have some equipment for catching suspicious conversion
> to/from/between enums:
>
> http://git.kernel.org/?p=devel/sparse/sparse.enum-warning.git
>
> Do you feel like writing a patch to replace the definition of unsigned char
> by definition of enum?

I could do that. We would then want some magic to re-define TRUE/FALSE
to those enum values (or it wouldn't be much of a point).
However, I just did some testing with bool and gcc+<stdbool.h>. It
doesn't seem to provide much protection as far as I can tell? A
variable of type 'bool' will happily accept anything, it seems.

-Tor
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-26