[pulseaudio-discuss] Transitioning from pa_bool_t to C99 bool

Tanu Kaskinen tanuk at iki.fi
Sat Jun 30 03:36:18 PDT 2012


Hi,

We handle booleans with these definitions:

/* This type is not intended to be used in exported APIs! Use classic "int" there! */
#ifdef HAVE_STD_BOOL
typedef bool pa_bool_t;
#else
typedef int pa_bool_t;
#endif

#ifndef FALSE
#define FALSE ((pa_bool_t) 0)
#endif

#ifndef TRUE
#define TRUE (!FALSE)
#endif

As far as I know, the "bool" data type is a feature of C99, and we also
rely on other other C99 features, so I don't think there's any benefit
in having the HAVE_STD_BOOL check, or compatibility problems if we drop
the check. We could define pa_bool_t as bool unconditionally. And if we
do that, then we could as well start using bool directly instead of
wrapping it in pa_bool_t.

Therefore, I propose that we deprecate pa_bool_t (I have a feeling that
someone has proposed that already before, but that discussion didn't go
anywhere). My proposal for the transition strategy is that pa_bool_t is
kept for now, but it would always be defined as bool. New boolean
variables should not use pa_bool_t. Old pa_bool_t uses would be
converted gradually like was done e.g. with pa_streq(). There was
recently a patch that changed all remaining strcmp() uses into
pa_streq(), and if someone wants to write a patch that converts all
pa_bool_t instances into bool in one go, that's fine for me.

What do others think?

-- 
Tanu



More information about the pulseaudio-discuss mailing list