views:

28

answers:

2

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?

+1  A: 

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") );
Klathzazt
+1  A: 

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).

dan04
That's exactly what I decided to do. I have simple toUTF16 and toUTF8 functions to interact with win32 API, and for the rest, I use std::string (UTF-8).
rubenvb