druntime
druntime copied to clipboard
set WCHAR to wchar_t for future
Part of transition to C++11 types. Blocked by https://github.com/dlang/dmd/pull/9029
Thanks for your pull request, @WalterBright!
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub fetch digger
dub run digger -- build "master + druntime#2390"
What does C++11 compatibility have to do with the Windows API? The Windows API is all C and does not use type mangling. Is it for non-Windows C++ APIs which use Windows API types?
What does C++11 compatibility have to do with the Windows API?
Microsoft changed the definition of WCHAR to wchar_t. Meaning D cannot connect to C++ code that uses WCHAR. It'll get worse with increasing use of char16_t.
They didn't 'change' the definition of WCHAR to wchar_t, that's just how it is for C++. For C, it's defined as unsigned short. It's always been this way.
Right, and for C it doesn't matter anyway because there is no mangling.
And for MS code, it just so happens that wchar_t matches unsigned short, and also that WINAPI is extern(C), not C++... but the type definitions and value of the macros has never changed.
Right, and for C it doesn't matter anyway because there is no mangling.
Right, but there is a gotcha case, which MS have a hack to deal with; back in the old days, when programmers wrote C and WCHAR was unsigned short, other developers would write compatible API's, but they would use unsigned short in their API's that received strings (because they didn't want to #include <windows.h> to get WCHAR... so there are/were a lot of string API's that used unsigned short explicitly instead of WCHAR, and then when those C API's were compiled with a C++ compiler, there were linkage problems, so VC++ has a hack to mangle WCHAR as unsigned short.
It's wrong, but the hack exists.
It's all old deprecated junk though, we shouldn't bother ourselves with any of that history.
we shouldn't bother ourselves with any of that history
Indeed, microsoft explicitly recommend against using that flag.