← Back to team overview

maria-developers team mailing list archive

Re: TRUE vs true (was: [Commits] ac05f41: postreview fix)

 

Hi, Sergey!

Yup.

I use TRUE/FALSE for my_bool in C and true/false for bool in C++.

With the only expection of return values where 0 conventionally means
success and non-zero means an error. As Mark Callaghan once commented

  bool somefunc()
  {
     ...
     /* got an error */
     return true;
     ...
     /* finished successfully */
     return false;
  }

looks pretty weird. I agree that true for an error and false for a
success is kind of counter-intuitive.  So in this case I use 1 and 0.

Regards,
Sergei

On Apr 23, 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>
> 
> I'm aware of only one more or less good reason for not using true/false in C++:
> it's easier to convert it to C code. But that's rare: we mostly convert in the
> opposite direction.
> 
> Also C99 now supports true/false, e.g. see nice description:
> http://www.jacquesf.com/2011/04/in-defense-of-the-c99-boolean-type/
> 
> Regards,
> Sergey


References