On Wed, 2025-01-15 at 18:25 +0000, Joseph Myers wrote:
> On Wed, 15 Jan 2025, David Malcolm wrote:
> 
> > +<p>
> > +  In C99 and later you can use <code>#include
> > &lt;stdbool.h&gt;</code>
> > +  which provides a definition of <code>bool</code> compatible with
> > C23.
> > +</p>
> > +  Note that the <code>bool</code> type is <b>not</b> the same
> > +  as <code>int</code> at ABI level, and so care may be needed
> > porting
> > +  declarations that appear at an ABI boundary (or serialized to
> > the
> > +  filesystem.
> > +</p>
> 
> OK, though this last paragraph should probably have an opening <p>,
> and as 
> discussed on IRC it might make sense to mention that C99/C23 bool can
> only 
> store values 0 and 1.  Maybe also mention that <stdbool.h> provides
> all of 
> bool, true and false (not just bool).

Thanks; I've pushed this version of the patch:

---
 htdocs/gcc-15/porting_to.html | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/htdocs/gcc-15/porting_to.html b/htdocs/gcc-
15/porting_to.html
index e6da6cd9..7344afa5 100644
--- a/htdocs/gcc-15/porting_to.html
+++ b/htdocs/gcc-15/porting_to.html
@@ -43,6 +43,36 @@ to your build flags, or port your code to C23.
 
 <!-- C23 brings the following changes: -->
 
+<h4 id="c23-new-keywords">New keywords</h4>
+<p>
+  C23 added various new keywords, including
+  <code>bool</code>, <code>true</code>, <code>false</code>,
+  <code>nullptr</code>, and <code>thread_local</code>.
+  Code that uses these for identifiers will need changing.
+  For example <code>typedef int bool;</code> will
+  <a href="https://godbolt.org/z/7W8fMT9zd";>fail</a> with:
+</p>
+<pre><code>
+&lt;source&gt;:1:13: error: 'bool' cannot be defined via 'typedef'
+    1 | typedef int bool;
+      |             ^~~~
+&lt;source&gt;:1:13: note: 'bool' is a keyword with '-std=c23' onwards
+&lt;source&gt;:1:1: warning: useless type name in empty declaration
+    1 | typedef int bool;
+      | ^~~~~~~
+</code></pre>
+<p>
+  In C99 and later you can use <code>#include &lt;stdbool.h&gt;</code>
+  which provides definitions of <code>bool</code>, <code>true</code>,
+  and <code>false</code> compatible with C23.
+</p>
+<p>
+  Note that the <code>bool</code> type is <b>not</b> the same
+  as <code>int</code> at ABI level, and so care may be needed porting
+  declarations that appear at an ABI boundary (or serialized to the
+  filesystem).
+</p>
+
 <h2 id="cxx">C++ language issues</h2>
 
 <h3 id="header-dep-changes">Header dependency changes</h3>
-- 
2.46.0


Reply via email to