bool different in C and C++?
Berthold Stoeger
bstoeger at mail.tuwien.ac.at
Sat Nov 18 08:19:41 PST 2017
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?
Berthold
More information about the subsurface
mailing list