[libcxx-commits] [PATCH] D148542: [libc++] cuchar redeclares ::mbstate_t
Ian Anderson via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 18 17:10:42 PDT 2023
iana added a comment.
In D148542#4274624 <https://reviews.llvm.org/D148542#4274624>, @iana wrote:
> In D148542#4274570 <https://reviews.llvm.org/D148542#4274570>, @philnik wrote:
>
>> Why do we want to change this? The current version looks just fine.
>
> The redeclaration becomes an error with clang modules when __mbstate_t.h and cuchar are in different modules.
I dug into it a little more. When <cuchar> is compiled all by itself on Apple platforms, `mbstate_t` isn't defined because Apple doesn't have a <uchar.h>, and <stddef.h> doesn't declare `mbstate_t` either. But when <__mbstate_t.h> (and <cwchar>) are compiled, they both get the OS declaration of `mbstate_t` and their `using` declaration gets a type. I think it works out with the current `std` mega module because declarations leak between the submodules, but when those three headers are in different top level modules, that's when things get mad at <cuchar>.
So it looks like it's fine to leave the `using ::mbstate_t _LIBCPP_USING_IF_EXISTS;` line in <cuchar>, but we need to include something to get `mbstate_t` defined. Do we want to unconditionally include __mbstate_t.h? That will have the side effect of often including <wchar.h>, and also declaring `::mbstate_t` which maybe we don't want. We could leave that include conditional on `_LIBCPP_CXX03_LANG`? Or we could instead include <bits/types/mbstate_t.h> or <sys/_types/_mbstate_t.h> to get just the C declaration?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148542/new/
https://reviews.llvm.org/D148542
More information about the libcxx-commits
mailing list