← Back to team overview

maria-developers team mailing list archive

Re: TRUE vs true

 

Hi Sanja,

yes, it is not a requirement to use true/false in C++.

I'd be Ok about my_bool if not one glitch: it can evaluate to anything that
char can evaluate to. C99 bool behaves more as expected:
<quot>
_Bool (also accessible as the macro bool) - type, capable of holding one of the
two values: 1 and 0 (also accessible as the macros true and false). Note that
conversion to _Bool does not work the same as conversion to other integer types:
(bool)0.5 evaluates to 1, whereas (int)0.5 evaluates to 0.
</quot>

I'd vote for bool/true/false everywhere if I were sure about it's portability
and about sizeof(_Bool) stability.

Regards,
Sergey

On Thu, Apr 23, 2015 at 11:02:16AM +0200, Oleksandr Byelkin wrote:
> On 23.04.15 10:14, Sergey Vojtovich wrote:
> >Hi!
> >
> >According to MySQL coding guidelines:
> >https://dev.mysql.com/doc/internals/en/additional-suggestions.html
> >
> ><quot>
> >* In C code, use TRUE and FALSE rather than 1/0
> >
> >* In C++ code, it is OK to use true and false (do not use 1/0). You can use C++
> >   bool/true/false when calling C functions (values will be safely promoted to
> >   my_bool).
> ></quot>
> 
> "It is OK" == "it is allowed to use it." (about true/false)
> 
> you have not use 1/0
> 
> and TRUE/FALSE must in C and OK in C++ (there is no other told)
> 
> So I should carefully check what code it is or just use TRUE/FALSE?
> 
> I prefer TRUE/FALSE everywhere.
> 
> [skip]


Follow ups

References