This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] <stdbool.h> should not define bool, true or false as macros for C++
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, jason at gcc dot gnu dot org
- Date: Mon, 9 Jan 2012 10:02:15 +0000
- Subject: Re: [patch] <stdbool.h> should not define bool, true or false as macros for C++
- References: <CAH6eHdQ4xWLYJEfYJ2ha-uebqGYZtWEsQkuFWQbp=eYFqDXQaA@mail.gmail.com>
I've just seen Richard's status email, so I guess this should wait for 4.8
On 9 January 2012 08:48, Jonathan Wakely wrote:
> GCC's implementation of <stdbool.h> is not valid for C++11 because
> [support.runtime] p8 says "The header <cstdbool> and the header
> <stdbool.h> shall not deïne macros named bool, true, or false."
>
> This patch adds a libstdc++ test for that requirement and adjusts
> stdbool.h to meet it. ÂI've left _Bool defined in C++ as a GNU
> extension.
>
> It's conceivable someone is relying on these macros being defined in
> C++, in which case we could only define them when __cplusplus <
> 201103L, but IMHO it's better to not define them at all.
>
> Tested x86_64-linux, OK for trunk?
>
> gcc/
> Â Â Â Â* ginclude/stdbool.h (true, false, bool): Do not define for C++.
>
> libstdc++/
> Â Â Â Â* testsuite/18_support/headers/cstdbool/macros.cc: New.