From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11766 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Clark Newsgroups: gmane.linux.lib.musl.general Subject: Re: stdbool.h does not define _Bool when included by C++ code Date: Tue, 01 Aug 2017 09:06:01 +1200 Message-ID: <53FF0182-D2D6-4D9D-9E99-5C9848A2A184@mac.com> References: <20170731091828.GA15263@port70.net> <20170731114623.0a449442@inria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1501535184 28158 195.159.176.226 (31 Jul 2017 21:06:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 31 Jul 2017 21:06:24 +0000 (UTC) Cc: musl@lists.openwall.com To: Jens Gustedt Original-X-From: musl-return-11779-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 31 23:06:18 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dcHtI-0006sN-1I for gllmg-musl@m.gmane.org; Mon, 31 Jul 2017 23:06:16 +0200 Original-Received: (qmail 12100 invoked by uid 550); 31 Jul 2017 21:06:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 12082 invoked from network); 31 Jul 2017 21:06:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=04042017; t=1501535167; bh=Kd4Uq3aDh9tLdKYsFzJey8cO9AwOt/5gzTtZYtKjne4=; h=Content-type:MIME-version:Subject:From:Date:Message-id:To; b=S0kr9wt5bxBtF5mMg0lOh1dg1zGorCjvgkCAXXInC94zT6nOAU4LLblYEv4CH8OBf 2eiaImz9HsKdaaj3wSx/+vmVszNEO330xKs7aUwuSfAlps9MO0PQujYbXTOAno6XkP EXj5xDFVN0S0/opPS33jUyb7Hl+Qm/7nqZByKBgLNVBTEnaegl0USyzYwr7ACJPmCK l3Ntznoh3t79PR+cJHRm9p6qQ2HS+/freyEMrMsMsyD5MlVOi37d6wEmhRgS6uMChM 1Vy29WSbRgnSFljziltYv5jRPd5i1WUHo4PlebV5tsV6bbGlI1YffAuhIzBeHWauvD qecLfNbopjYMw== X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-31_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1701120000 definitions=main-1707310353 In-reply-to: <20170731114623.0a449442@inria.fr> X-Mailer: Apple Mail (2.3273) Xref: news.gmane.org gmane.linux.lib.musl.general:11766 Archived-At: > On 31 Jul 2017, at 9:46 PM, Jens Gustedt = wrote: >=20 > Hello, >=20 > On Mon, 31 Jul 2017 11:18:28 +0200 Szabolcs Nagy = wrote: >=20 >> iow, this is either a minor gcc bug or a big fat c++ defect >> depending on how you look at it, the libc cannot fix this >> properly, just emulate the broken nonsense in gcc stdbool.h >> that nobody should rely on. >=20 > Basically stdbool.h is already a header to accomodate C++ usage of > bool, false and true to C. I makes not much sense to include this > in C++ code. It=E2=80=99s useful exactly for the case where you have C code in your = C++, which is why I suspect GCC has the condition in its version of = stdbool.h > I think that applications that want to be shure that their code > compiles for both should use "bool" and should do >=20 > #ifndef __cplusplus > # include > #endif I think you=E2=80=99re missing the point. C code can use _Bool and this = can be put through the C++ front-end. Compiler explorer does this by = default, and the GCC and glibc headers already have the fix, which is = #define _Bool bool (in the patch) for the case where C code is fed in to = the C++ front end. Have a look at gcc=E2=80=99s stdbool.h Notice that compiler has all the signs that it is actually C, including = using gcc and clang in the compiler labels instead of g++ and clang++ - https://godbolt.org/g/rhEZCx There are both C and C++ users who use compiler explorer, and it seems = the C users will have to add casts to malloc return values and what not. = Notice the dissasembly has de-mangled type-safe linkage. It=E2=80=99s = useful because you can see the arity of the function in compiler = explorer disassembly. > We can put more comfort into this by lifting this #ifndef/#endif stuff > to the contents of the file, if people really want this. But code that > relies on this would not be guaranteed to be portable. >=20 > Using "bool" by means of the header is the intended usage, these > attrocities such as _Bool, _Noreturn etc are only there for backwards > compatibility. Hopefully at least some of them will be phased out in > the future. >=20 > I think we should not encourage the usage of these keywords in > application code unless this is needed for backwards compatibility, > nor should we try to impose their possible usage into other languages. In any case the workaround is to rm PREFIX/include/stdbool.h so that the = libgcc version gets included. It=E2=80=99s essentially discouraging C++ users who want more conformity = with C.=