bool different in C and C++?

Berthold Stoeger bstoeger at mail.tuwien.ac.at
Sat Nov 18 10:40:17 PST 2017


On Samstag, 18. November 2017 19:11:53 CET Linus Torvalds wrote:
> On Sat, Nov 18, 2017 at 9:26 AM, Berthold Stoeger
> 
> <bstoeger at mail.tuwien.ac.at> wrote:
> > Sure, but can these definitions be different for C and C++ on any sane
> > platform?
> 
> Historically, yes, very much.

Thank you, that was an interesting read.

> [...]
> 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.

Berthold


More information about the subsurface mailing list