gpt4 book ai didi

c++ - 将 std::wstring 移植到 gcc cygwin

转载 作者:行者123 更新时间:2023-11-28 00:19:39 26 4
gpt4 key购买 nike

我正在尝试将一个用 Visual Studio 2010 编写的项目从 Microsoft 编译器移植到 gcc Cygwin。我的问题是 gcc Cygwin 或 gcc 是否支持 std::wstring ?有解决办法吗?

最佳答案

是的。它支持,但并不容易。

To support wstring, your platform needs to support a whole bunch of wchar_t functionality. q.v. Standard C++ IOStreams and Locales by Langer and Kreft.

It's really not enough to say "Hey, we've got wchar_t, and wchar_t character traits, so we can turn on std::wstring." The platform also needs to provide support for the C++ wide character I/O: wistream, wostream, facet, cvt, locale. And that's where things become problematic.

For Cygwin on Windows, the platform is Cygwin (and its amazingly cool POSIX API layer) moreso than the WinAPI.

ASIDE: I'm not sure what the MinGW situation is, but since MinGW uses WinAPI directly rather than having a more Unix-like POSIX API as the approach, MinGW may not be in this Cygwin situation.

Windows does support that functionality, but it appears that no one has gone through the considerable effort of plumbing up Cygwin to use those facilities. (Those are the FooW routines, rather than the FooA routines, in the WinAPI. And there is a lot of work to get the locale magic to work correctly.)

Also, Windows uses a wchar_t of 2 bytes. (Previous UCS-2, from the Unicode 1.0 era. Now with Vista and Win7, it's UTF-16.) It would be a bit retro to have Cygwin use a 2 byte wchar_t, rather than a 4 byte wchar_t. That just makes everything a little more difficult.

有关详细信息,请转到 gcc.gnu.org/ml/gcc-help:

关于c++ - 将 std::wstring 移植到 gcc cygwin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28199950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com