开发者

win32 c++ fstream wide argument

开发者 https://www.devze.com 2023-01-11 13:55 出处:网络
See link for what I\'m talking about. I want to use point 1 in the link and #define tfopen _wfopen #define _T(s) L##s

See link for what I'm talking about.

I want to use point 1 in the link and

#define tfopen _wfopen
#define _T(s) L##s

to do exactly what the link says is possible:

std::ifstream file( tfopen("filename.txt", _T("r") );

But gcc (mingw) 4开发者_如何学JAVA.4 says there's no matching call...

Am I doing it wrong or is the info in the link above incorrect?


You need to use the macro for the first parameter to tfopen, which in your case is "filename.txt"

std::ifstream file( tfopen(_T("filename.txt"), _T("r") );


The simple answer is that you're missing a _T. However, you may want to rethink the entire TCHAR approach and just call _wfopen (assuming Windows-only code).

0

精彩评论

暂无评论...
验证码 换一张
取 消