<div class="gmail_quote">2011/6/30 Ruben Van Boxem <span dir="ltr"><<a href="mailto:vanboxem.ruben@gmail.com">vanboxem.ruben@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2011/6/30 Howard Hinnant <<a href="mailto:hhinnant@apple.com">hhinnant@apple.com</a>>:<br>
<div class="im">><br>
> On Jun 28, 2011, at 3:15 PM, Ruben Van Boxem wrote:<br>
><br>
>> This is a larger patch with a bit more changes. I added a<br>
>> win32/support.h/cpp to add any missing functionality. For now that's<br>
>> only a simple enum and a simple vasprintf implementation.<br>
>><br>
>> Note that to get as far as this, with the current _STD macro problem<br>
>> (because it is used internally in the MS headers), you need to add a<br>
>> temporary workaround #define in the problematic file. That does not<br>
>> have to be committed!<br>
><br>
> I'll just change _STD to _VSTD (versioned std).  Is _VSTD already taken on windows?<br>
<br>
</div>a "grep -r "_VSTD" ." in the MSVC 10 include directory, the mingw-w64<br>
include directory, and the Windows SDK v7.1 include directory turned<br>
up no results, so this should be fine.<br>
<div class="im"><br>
><br>
>><br>
>> The cerrno macro's are from Boost, so "yes, they are correct", and<br>
>> "no, there are no license restrictions whatsoever". The _strto*_l<br>
>> functions are available on Windows msvcrt version 7. That's the<br>
>> default somewhere Vista/7-ish, so those aren't available on XP. I<br>
>> believe the Linux locale patch also takes into consideration providing<br>
>> a Windows alternative with little or no modification.<br>
><br>
> These constants appear to me to be public knowledge (i.e. no copyright issues).<br>
<br>
</div>Good to know. Although the bottom of the mingw-w64 header here<br>
<div class="im"><a href="http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-headers/include/psdk_inc/_wsa_errnos.h?revision=3546&view=markup" target="_blank">http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-headers/include/psdk_inc/_wsa_errnos.h?revision=3546&view=markup</a><br>

</div>seems to imply there are more sensible defines (without that many<br>
magic numbers, mostly to WSAE* codes which ought to come from<br>
<winsock2.h>). I cannot judge the difference though...<br>
<div class="im"><br>
><br>
>><br>
>> I'm quite sure the win32/support.h/cpp isn't the nicest solution,<br>
>> please do as you wish, there just needs to be a central place to add<br>
>> missing fundamental functionality. Perhaps a larger splitting of OS<br>
>> dependent functionality might be appropriate in the future.<br>
>><br>
>> As of with this patch (which includes the _STD clash workaround, I am<br>
>> now stranded at the catopen call in __locale, which as a little<br>
>> googling shows is very non-Windows-ish, and perhaps needs a lot more<br>
>> than just extra constants, #defines and #includes.<br>
>><br>
>> I would be pleased if anyone would commit at least the part of it they like :)<br>
><br>
> Let me commit the _STD -> _VSTD first, and then create a new patch using that.<br>
<br>
</div>Thanks! I'd like to do more, but I think I've reached my knowledge and<br>
capability limits. Some Windows guru (or even better, a Windows C++<br>
guru) will have to step up and implement more of libc++ to be usable.<br>
Remember that the _strto*_l functions are very new, and most probably<br>
don't work on XP, and may not work on Vista. I look to the Linux patch<br>
on this and *hope* it is general/compatible enough to work without<br>
much modification on Windows as well.<br></blockquote><div><br>I have finally gotten to more libc++ Windows work, and attached is a patch that addresses some of the issues that pop up. I know it's a lot to take in, but most changes are pretty logical (or I wouldn't have been able to find/code them). I'm currently facing implementing  wcsnrtombs and after that there's the more troubling issue of catgets and associates, which I'm quite worried about, as Win32 is almost orthogonal to this whole API. Ideas for that are very welcome.<br>
<br>The patch explained:<br>- include/__config/type_traits: add a define _LIBCXX_HAS_FEATURE_IS_BASE_OF for MSVC and GCC, which both have this, but not __has_feature, which is Clang-only. Modify <type_traits> accordingly.<br>
 - include/locale: Win32 does not have nl_types, which really sucks... big time.<br> - include/cerrno: the missing error constants, very much acceptable as said by Howard in this thread some time ago.<br> - include/__locale: include the new support/win32/locale.h header, and leave out the missing xlocale.h. Maybe a stupid name, but I haven't found a better name for it. Maybe once the whole win32 stuff is complete, some refactoring is in order. The mask type is defined and all values are defined to the correct values (extracted from mingw-w64 headers).<br>
 - include/support/win32/support.h: a place for missing functions' declarations to live.<br> - include/support/win32/locale.h: locale-related stuff (duh!) missing or otherwise defined in Win32 headers.<br> - CMakeLists.txt: add the new files, only on Win32.<br>
 - src/support/win32/support.cpp: implementation of functions in include/support/win32/support.h.<br><br>All this should work for both MinGW(-w64)/GCC and Microsoft/MSVC headers/libraries. Note the *_l functions are only available on recent Windows versions, which should be good enough for now. Especially the locale stuff (up till now!) should work for more than only plain "C" locale.<br>
<br>One point of attention: the FIXME in the new locale.h header needs attention: Win32 needs to call a function to enable thread-local locales, and then setlocale operates on the thread's locale, which is great. But this function needs to be called somewhere before everything else (in some static initialization function or something). On top of that, I'm not quite sure that what I do in my short implementation of uselocale is correct. I think it is, and it definitely is inefficient.<br>
<br>I tested this on GCC and Clang built for mingw-w64.<br><br>Please review and commit if you're OK. Thanks!<br><br>Ruben<br><br>PS: any further help is very much appreciated!<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<font color="#888888"><br>
Ruben<br>
</font></blockquote></div><br>