_O_WTEXT, _O_U16TEXT, _O_U8TEXT - are these modes possible in mingw compiler, are there any workarounds?(_O_WTEXT、_O_U16TEXT、_O_U8TEXT - 这些模式在 mingw 编译器中是否可行,是否有任何解决方法?)
问题描述
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main(void) {
_setmode(_fileno(stdout), _O_U16TEXT);
wprintf(L"x043ax043ex0448x043ax0430 x65e5x672cx56fd
");
return 0;
}
编译时返回错误:_O_U16TEXT 未在此范围内声明
这是这个编译器的亮点吗?
Is this a show-stopper with this compiler ?
推荐答案
好吧,有一个简单的解决方法:只需使用这些常量的值而不是它们的名称.例如,_O_U16TEXT 为 0x00020000,_O_U8TEXT 为 0x00040000.
Well, there's a simple workaround: just use values of these constants instead of their names. For example, _O_U16TEXT is 0x00020000 and _O_U8TEXT is 0x00040000.
我刚刚确认它可以在 Windows 10 上使用 g++ 4.8.1 与 _setmode 一起使用:
I've just confirmed that it works with _setmode using g++ 4.8.1 on Windows 10:
#include <iostream>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main() {
_setmode(_fileno(stdout), 0x00020000); // _O_U16TEXT
std::wcout << L"Русский текст
";
}
这篇关于_O_WTEXT、_O_U16TEXT、_O_U8TEXT - 这些模式在 mingw 编译器中是否可行,是否有任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:_O_WTEXT、_O_U16TEXT、_O_U8TEXT - 这些模式在 mingw 编译器中是否可行,是否有任何解决方法?
基础教程推荐
- c++ STL设置差异 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
