<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2155: Macro __bool_true_false_are_defined should be removed</title>
<meta property="og:title" content="Issue 2155: Macro __bool_true_false_are_defined should be removed">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2155.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#Resolved">Resolved</a> status.</em></p>
<h3 id="2155"><a href="lwg-defects.html#2155">2155</a>. Macro <code>__bool_true_false_are_defined</code> should be removed</h3>
<p><b>Section:</b> 17.14 <a href="https://wg21.link/support.runtime">[support.runtime]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Thomas Plum <b>Opened:</b> 2012-04-30 <b>Last modified:</b> 2020-11-09</p>
<p><b>Priority: </b>4
</p>
<p><b>View all other</b> <a href="lwg-index.html#support.runtime">issues</a> in [support.runtime].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>

<p>
Since C99, the C standard describes a macro named  <code>__bool_true_false_are_defined</code>.
<p/>
In the process of harmonizing C++11 with C99, this name became part of the C++ standard.
<p/>
I propose that all mention of this name should be removed from the C and C++ standards.
<p/>
Here's the problem: The name was originally proposed as a transition tool, so that the headers for a 
project could contain lines like the following.
</p>
<blockquote><pre>
#if !defined(__bool_true_false_are_defined)
#define bool int /* or whatever */
#define true 1
#define false 0
#endif
</pre></blockquote>
<p>
Then when the project was compiled by a "new" compiler that implemented <code>bool</code> as defined by the 
evolving C++98 or C99 standards, those lines would be skipped; but when compiled by an "old" compiler that 
didn't yet provide <code>bool</code>, <code>true</code>, and <code>false</code>, then the <code>#define</code>'s would provide a
simulation that worked for most purposes.
<p/>
It turns out that there is an unfortunate ambiguity in the name.  One interpretation is as shown above, but 
a different reading says "bool, true, and false are #define'd", i.e. that the meaning of the macro is to
assert that these names are macros (not built-in) ... which is true in C, but not in C++.
<p/>
In C++11, the name appears in parentheses followed by a stray period, so
some editorial change is needed in any event:
<p/>
17.14 <a href="https://wg21.link/support.runtime">[support.runtime]</a> para 1:
</p>
<blockquote><p>
Headers <code>&lt;csetjmp&gt;</code> (nonlocal jumps), <code>&lt;csignal&gt;</code> (signal handling), <code>&lt;cstdalign&gt;</code> 
(alignment), <code>&lt;cstdarg&gt;</code> (variable arguments), <code>&lt;cstdbool&gt;</code> (<code>__bool_true_false_are_defined</code>). 
<code>&lt;cstdlib&gt;</code> (runtime environment <code>getenv()</code>, <code>system()</code>), and <code>&lt;ctime&gt;</code> 
(system clock <code>clock()</code>, <code>time()</code>) provide further compatibility with C code.
</p></blockquote>
<p>
However, para 2 says
</p>
<blockquote><p>
"The contents of these headers are the same as the Standard C library headers <code>&lt;setjmp.h&gt;</code>, 
<code>&lt;signal.h&gt;</code>, <code>&lt;stdalign.h&gt;</code>, <code>&lt;stdarg.h&gt;</code>, <code>&lt;stdbool.h&gt;</code>, 
<code>&lt;stdlib.h&gt;</code>, and <code>&lt;time.h&gt;</code>, respectively, with the following 
changes:",
</p></blockquote>
<p>
and para 8 says 
</p>
<blockquote><p>
"The header <code>&lt;cstdbool&gt;</code> and the header <code>&lt;stdbool.h&gt;</code> shall 
not define macros named <code>bool</code>, <code>true</code>, or <code>false</code>."
</p></blockquote>
<p>
Thus para 8 doesn't exempt the C++ implementation from the arguably clear requirement of the C standard, to 
provide a macro named <code>__bool_true_false_are_defined</code> defined to be 1.
<p/>
Real implementations of the C++ library differ, so the user cannot count upon any consistency; furthermore, the 
usefulness of the transition tool has faded long ago.
<p/>
That's why my suggestion is that both C and C++ standards should eliminate any mention of 
<code>__bool_true_false_are_defined</code>.  In that case, the name belongs to implementers to provide, or not, as 
they choose.
</p>

<p><i>[2013-03-15 Issues Teleconference]</i></p>

<p>
Moved to Open.
</p>
<p>
While not strictly necessary, the clean-up look good.
</p>
<p>
We would like to hear from our C liaison before moving on this issue though.
</p>

<p><i>[2015-05 Lenexa]</i></p>

<p>
LWG agrees. Jonathan provides wording.
</p>

<p><i>[2017-03-04, Kona]</i></p>

<p>The reference to &lt;cstdbool&gt; in p2 needs to be struck as well. Continue the discussion on the reflector once the DIS is available.</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to N4296.</p>

<ol>
<li>
<p>Edit the footnote on 16.4.2.3 <a href="https://wg21.link/headers">[headers]</a> p7:</p>
<blockquote>
<p>
176) In particular, including <ins>any of</ins> the standard header<ins>s <code>&lt;stdbool.h&gt;</code>, <code>&lt;cstdbool&gt;</code>,</ins> <code>&lt;iso646.h&gt;</code> or <code>&lt;ciso646&gt;</code> has no effect.
</p>
</blockquote>
</li>

<li>
<p>Edit 17.14 <a href="https://wg21.link/support.runtime">[support.runtime]</a> p1 as indicated (and remove the index entry for <code>__bool_true_false_are_defined</code>):</p>

<blockquote>
<p>
-1- Headers <code>&lt;csetjmp&gt;</code> (nonlocal jumps), <code>&lt;csignal&gt;</code> (signal handling), <code>&lt;cstdalign&gt;</code> (alignment), <code>&lt;cstdarg&gt;</code> (variable arguments), <code>&lt;cstdbool&gt;</code><ins>,</ins><del> (<code>__bool_true_false_are_defined</code>).</del> <code>&lt;cstdlib&gt;</code> (runtime environment <code>getenv()</code>, <code>system()</code>), and <code>&lt;ctime&gt;</code> (system clock <code>clock()</code>, <code>time()</code>) provide further compatibility with C code.
</p>
</blockquote>
</li>

<li>
<p>Remove Table 38 &mdash; Header <code>&lt;cstdbool&gt;</code> synopsis [tab:support.hdr.cstdbool] from 17.14 <a href="https://wg21.link/support.runtime">[support.runtime]</a> </p>
<blockquote>
<table border="1">
<caption> Table 38 &mdash; Header <code>&lt;cstdbool&gt;</code> synopsis </caption>
<tr><td><b>Type</b></td><td><b>Name(s)</b></td></tr>
<tr><td><b>Macro:</b></td><td><code>__bool_true_false_are_defined</code></td></tr>
</table>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2019-03-18; Daniel comments and eliminates previously proposed wording]</i></p>

<p>
With the approval of <a href="https://wg21.link/p0619r4">P0619R4</a> in Rapperswil, the offending wording has now been eliminated 
from the working draft. I suggest to close this issue as: Resolved by <a href="https://wg21.link/p0619r4">P0619R4</a>.
</p>
<p><i>[2020-11-09 Resolved for C++20. Status changed: Tentatively Resolved &rarr; Resolved.]</i></p>



<p><b>Rationale:</b></p>
Resolved by <a href="https://wg21.link/p0619r4">P0619R4</a>.


<p id="res-2155"><b>Proposed resolution:</b></p>





</body>
</html>
