1

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?

rubenvb
  • 74,642
  • 33
  • 187
  • 332

2 Answers2

1

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
  • 2,415
  • 19
  • 27
1

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

Community
  • 1
  • 1
dan04
  • 87,747
  • 23
  • 163
  • 198
  • 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 Aug 26 '10 at 08:44