mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <>
To: Markus Wichmann <>
Cc:, Peter Collingbourne <>
Subject: Re: [musl] [PATCH] arm: Use __WCHAR_TYPE__ for wchar_t if defined
Date: Sun, 5 Feb 2023 18:49:31 -0500	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <20230205200003.GA1998@voyager>

On Sun, Feb 05, 2023 at 09:00:03PM +0100, Markus Wichmann wrote:
> On Sat, Feb 04, 2023 at 08:08:36AM +0100, alice wrote:
> > On Sat Feb 4, 2023 at 7:30 AM CET, Peter Collingbourne wrote:
> > > When building with -fshort-wchar the definition of wchar_t is
> > > incorrect. Get the correct definition from the compiler if available.
> > >
> > > This is useful when reusing the freestanding parts of musl on a
> > > bare-metal target that uses -fshort-wchar.
> >
> > somebody talked about this in 2015, see
> >
> > for the previous discussion.
> >
> > i understand in this case it's proposed a little different-
> > "reusing freestanding parts" as opposed to building a whole, but in
> > that case you could most likely patch this in when reusing it standalone only?
> >
> > it doesn't seem a good idea for it to be there, in general.
> Seconded. A lot of code in musl depends on wchar_t being able to hold
> the current maximum Unicode codepoint of 0x10FFFF at least, so the type
> must be at least 21 bits.

Absolutely. -fshort-wchar requests a different ABI that is
fundamentally incompatible with libc and with use of the libc headers,
and also fundamentally incompatible with Unicode and the requirements
of the C language (unless you only want to support the BMP) -- C does
not allow "multi-wchar_t characters".

If you're targeting freestanding environment not using libc, you
should use -nostdinc and provide headers suitable to your environment
instead of the libc ones. But really you should fix the offending code
not to use wchar_t for UTF-16, and not use -fshort-wchar. Modern C has
a char16_t type for this purpose.


  reply	other threads:[~2023-02-05 23:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04  6:30 Peter Collingbourne
2023-02-04  7:08 ` alice
2023-02-05 20:00   ` Markus Wichmann
2023-02-05 23:49     ` Rich Felker [this message]
2023-02-07  1:15       ` Peter Collingbourne
2023-02-07 14:59         ` Rich Felker

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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

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).