Skip to content

libc++ requires mbstate_t even when we disable support for wide characters #84884

Open
@petrhosek

Description

@petrhosek

Even when we disable support for wide characters with _LIBCPP_HAS_NO_WIDE_CHARACTERS, libc++ still requires the definition of mbstate_t.

In file included from /llvm_libcxx/include/algorithm:1955:
In file included from /llvm_libcxx/include/__algorithm/ranges_sample.h:13:
In file included from /llvm_libcxx/include/__algorithm/sample.h:18:
In file included from /llvm_libcxx/include/__random/uniform_int_distribution.h:20:
In file included from /llvm_libcxx/include/iosfwd:117: 
In file included from /llvm_libcxx/include/__std_mbstate_t.h:14:
/llvm_libcxx/include/__mbstate_t.h:51:4: error: "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
   51 | #  error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
      |    ^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
In file included from /llvm_libcxx/include/algorithm:1955:                                                                                                                                                                                                                                                                                                                             
In file included from /llvm_libcxx/include/__algorithm/ranges_sample.h:13:                                                                                                                                                                                                                                                                                                             
In file included from /llvm_libcxx/include/__algorithm/sample.h:18:                                                                                                                                                                                                                                                                                                                    
In file included from /llvm_libcxx/include/__random/uniform_int_distribution.h:20:                                                                                                                                                                                                                                                                                                     
/llvm_libcxx/include/iosfwd:135:14: error: reference to unresolved using declaration                                                                                                                                                                                                                                                                                                   
  135 | typedef fpos<mbstate_t> streampos;                                                                                                                                                                                                                                                                                                                                                                                                
      |              ^                                                                                                                                                                                                                                                                                                                                                                                                                    
/llvm_libcxx/include/__std_mbstate_t.h:25:1: note: using declaration annotated with 'using_if_exists' here                                                                                                                                                                                                                                                                             
   25 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS;                                                                                                                                                                                                                                                                                                                                                                                        
      | ^

The workaround used by some of the platforms is to define an empty mbstate_t, but ideally this shouldn't be needed at all.

This is related to issue #84879.

Metadata

Metadata

Assignees

No one assigned

    Labels

    embeddedSupport for embedded developmentlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions