[pulseaudio-discuss] [PATCH 1/4] stream-restore: add volume_is_absolute bool in client side
lennart at poettering.net
Mon May 11 05:12:26 PDT 2009
On Mon, 11.05.09 12:56, Felipe Contreras (felipe.contreras at gmail.com) wrote:
> On Sat, May 9, 2009 at 3:14 PM, Lennart Poettering
> <lennart at poettering.net> wrote:
> > On Sat, 09.05.09 12:50, Felipe Contreras (felipe.contreras at gmail.com) wrote:
> >> > pa_bool_t is used internally only. In the public API we only expose
> >> > ints. pa_bool_t is defined as _Bool on C99 and int on other
> >> > compilers. This discrepancy should not be visible to outside due to
> >> > ABI stability issues.
> >> Minor comment; if you include stdbool.h you can use 'bool' which IMHO
> >> is less ugly than _Bool. And I wonder what's the point of pa_bool_t...
> >> if the compiler doesn't have stdbool.h, then just define 'bool' as you
> >> would define pa_bool_t.
> > There's not much difference between _Bool, and bool. Both are C99.
> Nope, the only difference is that 'bool' looks nicer :)
> > I guess 10 years after C99 it might be possible to drop C89
> > support. But uh, the API uses int for all bools and we should stick to
> > it for now.
> This is what I meant:
> #if HAVE_STDBOOL_H
> #include <stdbool.h>
> typedef unsigned char bool
Firstly that would require including config.h from public header
files which we don't do.
But more importantly this will break ABI when folks switch between C89
Also there are lots of subtle differences between 'unsigned
char'/'int' and 'bool'.
sizof(bool) is usually sizeof(int). However sizeof(bool) is !=
sizeof(unsigned char). In a struct defining 'bool foo:1' works fine
and then allows assignment of 1/0. However in a struct 'int foo:1'
allows assignment of -1/0 only.
Internally we actually use a definition like you suggested, but we
don't want to push that into the ABI and hence trigger breakage
there. Our definition is like this:
typedef _Bool pa_bool_t;
typedef int pa_bool_t;
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the pulseaudio-discuss