Re: bool different in C and C++?

2017-11-19 Thread Thiago Macieira
On sábado, 18 de novembro de 2017 08:19:41 PST Berthold Stoeger wrote: > in core/pref.h we find the comment > /* can't use 'bool' for the boolean values - different size in C and C++ */ The comment is wrong. It's been wrong for 18 years, since C99 introduced stdbool.h. -- Thiago Macieira - thia

Re: bool different in C and C++?

2017-11-19 Thread Berthold Stoeger
Hi Stefan, On Sonntag, 19. November 2017 23:07:43 CET Stefan Fuchs wrote: > 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 l

Re: bool different in C and C++?

2017-11-19 Thread Stefan Fuchs
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 > ap

Re: bool different in C and C++?

2017-11-18 Thread Linus Torvalds
On Sat, Nov 18, 2017 at 10:40 AM, Berthold Stoeger wrote: > > 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? We seem to depend on "bool" a lot, so might as well keep them that way. I actual

Re: bool different in C and C++?

2017-11-18 Thread Berthold Stoeger
On Samstag, 18. November 2017 19:11:53 CET Linus Torvalds wrote: > On Sat, Nov 18, 2017 at 9:26 AM, Berthold Stoeger > > 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. >

Re: bool different in C and C++?

2017-11-18 Thread Linus Torvalds
On Sat, Nov 18, 2017 at 9:26 AM, Berthold Stoeger wrote: > > Sure, but can these definitions be different for C and C++ on any sane > platform? Historically, yes, very much. "bool" didn't really exist in C, so you will find code that does #define int bool or typedef int bool; all over

Re: bool different in C and C++?

2017-11-18 Thread Lubomir I. Ivanov
On 18 November 2017 at 19:26, Berthold Stoeger wrote: > On Samstag, 18. November 2017 17:34:59 CET Lubomir I. Ivanov wrote: >> On 18 November 2017 at 18:19, Berthold Stoeger >> > On the other hand, many of the boolean settings are indeed defined as >> > short. Shouldn't this be made consistent? >>

Re: bool different in C and C++?

2017-11-18 Thread Berthold Stoeger
On Samstag, 18. November 2017 17:34:59 CET Lubomir I. Ivanov wrote: > On 18 November 2017 at 18:19, Berthold Stoeger > > On the other hand, many of the boolean settings are indeed defined as > > short. Shouldn't this be made consistent? > > both sizeof(short) and sizeof(bool) are implementation de

Re: bool different in C and C++?

2017-11-18 Thread Lubomir I. Ivanov
On 18 November 2017 at 18:19, Berthold Stoeger wrote: > Dear all, > > in core/pref.h we find the comment > /* can't use 'bool' for the boolean values - different size in C and C++ */ > > Ironically, the same file is full of bool struct members, so it seems to rely > on the fact that this comment i

bool different in C and C++?

2017-11-18 Thread Berthold Stoeger
Dear all, in core/pref.h we find the comment /* can't use 'bool' for the boolean values - different size in C and C++ */ Ironically, the same file is full of bool struct members, so it seems to rely on the fact that this comment is wrong. The fact is confirmed by my tests: #include #include i