[PATCH] D40181: [libcxx] Allow to set locale on Windows.

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 14:08:57 PST 2017


mstorsjo added a comment.

In order to make this work with MinGW (more or less), I had to change the `_LIBCPP_MSVCRT` into `_LIBCPP_MSVCRT_LIKE` both in `include/__locale` and in `include/__config` (where `_LIBCPP_LOCALE__L_EXTENSIONS` is defined). Normal mingw that uses msvcrt.dll doesn't have per-thread locales so it won't really work in any case (but I think it does define some sort of dummy functions that at least will allow it to build). Nowadays, mingw can be built to target ucrtbase.dll as well though, and there it should be possible to make it work just like for MSVC although it might need some patches.



================
Comment at: include/__locale:72
+        __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
+        __locale_str{
+            setlocale(LC_COLLATE, __l.__get_locale()),
----------------
This syntax only seems to work if the code using this is built in C++11 mode; this breaks building C++98 code.


================
Comment at: include/support/win32/locale_win32.h:57
+    
+    friend bool operator==(nullptr_t, const locale_t& __right) {
+        return nullptr == __right.__locale;
----------------
In my testing, I had to change all these `nullptr_t` into `std::nullptr_t` in order to build it successfully.


https://reviews.llvm.org/D40181





More information about the cfe-commits mailing list