bool different in C and C++?

Stefan Fuchs sfuchs at gmx.de
Sun Nov 19 14:07:43 PST 2017


Am 18.11.2017 um 19:40 schrieb Berthold Stoeger:
>> [...]
>> In fact, even when you can depend on a modern compiler, it's usually
>> best to restrict "bool" use entirely to just function return values
>> and very local use.
> I figure pref.h counts as such a local use, because it is purely an 
> application-internal thing? Or would you prefer going the short (or char?) 
> route?
>
> bool certainly has the advantage of correctly expressing intent in this case. 
> There are short members in pref.h which actually do represent integer values.
May I ask you s.th. mainly to learn s.th.:
I also once added a feature with an additional prefs option where I
would have preferred the new variable to be a bool. The variable is this
one here:
https://github.com/Subsurface-divelog/subsurface/blob/master/core/units.h#L266

Using bool there failed with a compiler error. Why was/am I not able to
use bool there but in prefs.h one can use bool?
I guess I'm missing s.th. very obvious?
BTW: I also read the comment in prefs.h about bool at this time and was
even more confused then ;-)

Best regards
Stefan

-- 

Stefan Fuchs
E-Mail: sfuchs at gmx.de <mailto:sfuchs at gmx.de>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171119/c0dd282b/attachment.html>


More information about the subsurface mailing list