10-215 To: J3 From: Nick Maclaren Subject: Interop TR: _Bool (5.2.5 Macros) Date: 2010 October 06 Reference: 10-165r2.pdf It is a serious mistake for the TR to either use or provide support for C99's 'boolean' type, for a great many reasons. The following is a very condensed summary of the situation. C99 has not been universally accepted by the IT community, and a great many important interfaces and applications explicitly require C90. Also, an equally large number use C++ and will want to use this interface via the defined C subset -- the standards are such that this can be argued to be defined behaviour. It therefore makes sense not to rely on or support anything that is not at least compatible between C90, C99 and C++. C99's '_Bool' and the (redefinable) macros 'bool', 'true' and 'false' from were introduced against strong opposition within WG14 as a hack to emulate C++'s 'bool' type, and they are largely but not entirely compatible - but ONLY at the source level. The question for the TR is whether they are compatible at the data representation level, and that is not required to be the case. C++0X (WG21 document n3092) makes no reference to _Bool (and therefore does not include it in the language), and says the following about header : __bool_true_false_are_defined is defined. [table 26, p. 460] The header and the header shall not define macros named bool, true and false. [18.10 support.runtime, p. 460] It is noteworthy that C99 makes no use of _Bool in any of the new functions that it has introduced into the library, and continues to use int for that purpose. Fortran should not tread new ground in C specifications! Also, _Bool and C++ bool are fundamentally non-interoperable with Fortran, because they have delights like being required to support arithmetic operations but with non-arithmetic semantics. There are more reasons not to touch _Bool, but that should be enough. There is also an error in 10-165r2.pdf, because the type is _Bool and not Bool. Edits to 10-165r2: 11:0+ In the entry for CFI_type_Bool in table 5.2, the C type "Bool" should be corrected to "_Bool". 12:14 "_Bool" should be replaced by "int". 12:15-16 "true" should be replaced by "1" and "false" by "0".