[MPlayer-dev-eng] int vs. bool

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Dec 1 08:10:56 CET 2012


On 1 Dec 2012, at 00:15, Ingo Brückl <ib at wupperonline.de> wrote:
> Reimar Döffinger wrote on Fri, 30 Nov 2012 19:42:31 +0100:
> 
>> 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?
> 
> I'm only referring to the GUI code, of course.
> 
>> 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.
> 
> Would
> 
>  #define bool int
>  #define false 0
>  #define true  1
> 
> in an own header file for the GUI be a better idea or don't you like bool
> at all and/or recommend against it?

That is even worse, using standard names with non-standard behaviour.

> I think the code will become more self-explanatory than directly using 0
> and 1 with int variables.

Why? Is this maybe something that can be solved by better variable names?
Otherwise the BOOL type name and TRUE/FALSE from Windows might be usable, I think it is simply defined to unsigned normally.
However the problem from my point of view is that there are no bool types in any CPU architecture I know of, so you will always end up with strange behaviour in some case.


More information about the MPlayer-dev-eng mailing list