From: Michael Clark <michaeljclark@mac.com>
To: musl@lists.openwall.com
Subject: stdbool.h does not define _Bool when included by C++ code
Date: Fri, 28 Jul 2017 22:21:10 +1200 [thread overview]
Message-ID: <A256987C-DE95-405D-9F26-3C54CC3B20A2@mac.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]
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 <https://cx.rv8.io/>
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
[-- Attachment #2.1: Type: text/html, Size: 1767 bytes --]
[-- Attachment #2.2: musl-stdbool-cplusplus.patch --]
[-- Type: application/octet-stream, Size: 267 bytes --]
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
[-- Attachment #2.3: Type: text/html, Size: 233 bytes --]
next reply other threads:[~2017-07-28 10:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-28 10:21 Michael Clark [this message]
2017-07-28 13:01 ` Rich Felker
2017-07-31 9:18 ` Szabolcs Nagy
2017-07-31 9:46 ` Jens Gustedt
2017-07-31 21:06 ` Michael Clark
2017-08-01 1:31 ` Rich Felker
2017-08-01 7:24 ` Jens Gustedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A256987C-DE95-405D-9F26-3C54CC3B20A2@mac.com \
--to=michaeljclark@mac.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).