问题描述
我正在Windows上使用带有MinGW工具链(g ++等)的Eclipse.我有一个基于darwin构建的程序,该程序使用wifstream和wofstream读写文件.该程序可编译并可以在darwin(Mac)上使用eclipse ...针对我的问题.
I am using Eclipse on windows with the MinGW tool chain (g++, etc.). I have a program that I built on darwin that reads and writes to files using wifstream and wofstream. The program comiles and works find using eclipse on darwin (Mac)...no for my problem.
当我将代码移到Windows并尝试使用MinGW工具链和Eclipse构建时,在wifstream,wofstream和wcout上出现编译错误.定义为wstring的变量可以很好地编译.
When I move the code over to windows and try to build in using the MinGW tool chain and eclipse, I get a compile error on wifstream, wofstream, and wcout. Variables defined as wstring compile just fine.
例如:
wifstream inFile;inFile.open(argv [2],ios_base :: in);
wifstream inFile;inFile.open(argv[2], ios_base::in);
导致编译错误
.. \ src \ pdConv.cpp:31:错误:未在此范围内声明"wifstream"
..\src\pdConv.cpp:31: error: `wifstream' was not declared in this scope
似乎表明编译器认为wifstream是一个变量.我确实注意到在包含文件中未启用_GLIBCXX_USE_WCHAR_T指令.我需要自己定义还是环境中的某些东西应该知道这一点?如果我手动定义它,那么看来我不能在同一程序中同时使用广泛和狭窄的实现方式.
which seems to indicate that the compiler thinks wifstream is a variable. I did notice that the _GLIBCXX_USE_WCHAR_T directive is not enabled in the include files. Do I need to define this myself or is something in the environment supposed to know this? If I define it manually then it appears I cant use both wide and narrow implementations in the same program.
这可能很明显,但是我已经在这个问题上停留了很长时间……哈哈..我在这里想念什么?
This is probably obvious but I have been stuck in this problem for to long...lol..What am I missing here?
推荐答案
基本上,MinGW不支持此功能.看到此链接我想可能有最新的gcc(4.4.0)可用于MinGW解决了这个问题,但我不会指望它.如果您需要坚持使用MinGW,则似乎只能使用STLPorts.
Basically, this isn't supported with MinGW. See this link I suppose it's possible the the very latest gcc (4.4.0) that is available for MinGW solves this, but I wouldn't count on it. Looks like using STLPorts might be your only option if you need to stick with MinGW.
这篇关于Windows上的iostream,wifstream和eclipse/g ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!