iostream, wifstream, and eclipse/g++ on windows

浪尽此生 提交于 2019-12-11 15:08:18

问题


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.

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.

For example:

wifstream inFile; inFile.open(argv[2], ios_base::in);

results in a compile error

..\src\pdConv.cpp:31: error: `wifstream' was not declared in this scope

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?


回答1:


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.



来源:https://stackoverflow.com/questions/1316962/iostream-wifstream-and-eclipse-g-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!