[MPlayer-dev-eng] int vs. bool
Alexander Strasser
eclipse7 at gmx.net
Sun Dec 2 00:45:40 CET 2012
Reimar Döffinger wrote:
> On Fri, Nov 30, 2012 at 07:09:53PM +0100, Ingo Brückl wrote:
> > Are there any objections to using data type bool, or are there disadvantages
> > or possible problems?
>
> IMHO it is not a good idea.
> 1) We are not using it anywhere, not even in FFmpeg
> 2) It was "only" added in C99 so in some special cases compiler support
> might still be lacking
> 3) In my experience, lots of developers are completely oblivious to its
> exact semantics and in particular which performance effects they have.
FWIW I agree with Reimar on this one:
Use just the plain old if ()/ternary operator semantics if you
just need a boolean type; like:
if (bool_var) // if bool_var is true
or
if (!bool_var) // if bool_var is false
OTOH if you need it for indexing (or similar) make sure you used
proper comparison operations or double negation before; like:
bool_var = x > y; // will end up as 0 or 1 exactly
or
bool_var = !!z; // z might have been e.g. -3 before
Doing anything else is IMHO not a fit for the C language...
Alexander
More information about the MPlayer-dev-eng
mailing list