_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 编译器中是否可行,是否有任何解决方法?
				
        
 
            
        基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
 - 如何通过C程序打开命令提示符Cmd 2022-12-09
 - C++结构和函数声明。为什么它不能编译? 2022-11-07
 - 我有静态或动态 boost 库吗? 2021-01-01
 - 这个宏可以转换成函数吗? 2022-01-01
 - 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
 - 在 C++ 中计算滚动/移动平均值 2021-01-01
 - 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
 - 常量变量在标题中不起作用 2021-01-01
 - 如何在 C++ 中初始化静态常量成员? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				