Search code examples
unicodewinapifstreamtchar

win32 c++ fstream wide argument


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.4 says there's no matching call...

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


Solution

  • 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") );