From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11749 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Clark Newsgroups: gmane.linux.lib.musl.general Subject: stdbool.h does not define _Bool when included by C++ code Date: Fri, 28 Jul 2017 22:21:10 +1200 Message-ID: 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: multipart/alternative; boundary="Apple-Mail=_A4115669-8518-4642-8380-27425A4EEF42" X-Trace: blaine.gmane.org 1501237296 20796 195.159.176.226 (28 Jul 2017 10:21:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 28 Jul 2017 10:21:36 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11762-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jul 28 12:21:31 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 1db2Oe-00051N-Sz for gllmg-musl@m.gmane.org; Fri, 28 Jul 2017 12:21:29 +0200 Original-Received: (qmail 15733 invoked by uid 550); 28 Jul 2017 10:21:30 -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 15694 invoked from network); 28 Jul 2017 10:21:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=04042017; t=1501237275; bh=sf62v8BBMoS1oPsC+xfV19zFx5sl1xQDXqGE8+dp0m8=; h=From:Content-type:MIME-version:Subject:Message-id:Date:To; b=wA1gbKpoS95YKYcftYPMggw1lnG3cI6WcVvyEioJ8XbzLC+yd3B374xsJKNbYx7LC J+S7nvWoXpOcaIcisAHpIdcLaLAn/VpDn1nmyoUBIctASYosottUKEfSdL0hI2OZe9 16OLcyL6PbaHrjlq5pscGLFyVDJTVZPokCZxQpm4rQ3nX7PbPpRsXxxZClBwacJrmT X0WpPf0nPKtkl43OwgTy7FZ0zIG6BRxj2l1CWEK+X33na8YNd45TFQ6r97J2f7yt7O 6Mkgvt+X2mDWnI4GFfFEHzASuUk/TJDNQt+PmJjVV0dUNJ5AtFijQ5bjeQU/y+9It7 hO1XcVtuiSmAg== X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1701120000 definitions=main-1707280159 X-Mailer: Apple Mail (2.3273) Xref: news.gmane.org gmane.linux.lib.musl.general:11749 Archived-At: --Apple-Mail=_A4115669-8518-4642-8380-27425A4EEF42 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, I noticed an issue with the musl headers when installing = compiler-explorer for RISC-V. Try compiling this code with g++ and = musl's stdbool.h - https://cx.rv8.io/g/Bc3AwY Compiler explorer uses the C++ front-end to the compiler by default It seems the musl stdbool.h defines bool in terms of _Bool for C, but = does not define _Bool in terms of bool for C++. The gcc stdbool.h header handles both conditions and when included by = C++ code it has #define _Bool bool but notes that it is a GNU extension. My workaround was to delete the musl stdbool.h so that the GCC version = is included, but it seems the header could work for C code passed = through the C++ front-end with a small patch (attached). The other musl = headers seem to support C++, so I think it might be nice to fix = stdbool.h for C code compiled through the C++ front-end. Of course C++ = code needs casts on malloc and there are several other differences such = as new reserved words, however for the most part, a lot of C code can = compile using the C++ front-end. Michael --Apple-Mail=_A4115669-8518-4642-8380-27425A4EEF42 Content-Type: multipart/mixed; boundary="Apple-Mail=_831CD0A8-ED7B-4E14-975B-B8DAD4D86964" --Apple-Mail=_831CD0A8-ED7B-4E14-975B-B8DAD4D86964 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Hi,

I = noticed an issue with the musl headers when installing compiler-explorer = for RISC-V. Try compiling this code with g++ and musl's = stdbool.h


Compiler explorer uses the C++ = front-end to the compiler by default

It seems the musl stdbool.h defines = bool in terms of _Bool for C, but does not define _Bool in terms of bool = for C++.

The = gcc stdbool.h header handles both conditions and when included by C++ = code it has #define _Bool bool but notes that it is a GNU = extension.

My = workaround was to delete the musl stdbool.h so that the GCC version is = included, but it seems the header could work for C code passed through = the C++ front-end with a small patch (attached). The other musl headers = seem to support C++, so I think it might be nice to fix stdbool.h for C = code compiled through the C++ front-end. Of course C++ code needs casts = on malloc and there are several other differences such as new reserved = words, however for the most part, a lot of C code can compile using the = C++ front-end.

Michael

= --Apple-Mail=_831CD0A8-ED7B-4E14-975B-B8DAD4D86964 Content-Disposition: attachment; filename=musl-stdbool-cplusplus.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="musl-stdbool-cplusplus.patch" Content-Transfer-Encoding: 7bit diff --git a/include/stdbool.h b/include/stdbool.h index a9d7ab7..06742f9 100644 --- a/include/stdbool.h +++ b/include/stdbool.h @@ -7,6 +7,10 @@ #define false 0 #define bool _Bool +#else + +#define _Bool bool + #endif #define __bool_true_false_are_defined 1 --Apple-Mail=_831CD0A8-ED7B-4E14-975B-B8DAD4D86964 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_831CD0A8-ED7B-4E14-975B-B8DAD4D86964-- --Apple-Mail=_A4115669-8518-4642-8380-27425A4EEF42--