On 18 November 2017 at 18:19, Berthold Stoeger <[email protected]> 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 is wrong. The fact is confirmed by my tests: > > #include <stdio.h> > #include <stdbool.h> > int main() > { > printf("%ld\n", sizeof(bool)); > } > > and > > #include <iostream> > int main() > { > std::cout << sizeof(bool) << '\n'; > } > > both output '1' for me when compiled with gcc and q++, respectively. > > 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 defined. i think this can be changed, yes...and let's see if we break something; bool should be mostly 1 byte everywhere. the only way to make sure that bool is always 1 byte is to homebrew it as: typedef char bool; lubomir -- _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
