#define __T(x) L ## x
Found in code from one of the MFC source header file. It is mostly used for converting strings to …….. (I don’t know what). If I am correct it converts strings to LPCTSTR…don’t know what that type is either…
I can’t seem to convert char* into LPCTSTR. While MFC file handling, the following code will always return error while trying to open the file…
char* filepath = "C:\\Program Files\\Microsoft Office\\Office12\\BITMAPS\\STYLES\\GLOBE.WMF";
if( !file.Open((LPCTSTR)filepath , CFile::modeRead, &fexp) )
{
fexp.ReportError();
return 1;
}
But instead if I wrote it this way, it doesn’t give error:
if( !file.Open( _T("C:\\Program Files\\Microsoft Office\\Office12\\BITMAPS\\STYLES\\GLOBE.WMF") , CFile::modeRead, &fexp) )
{
fexp.ReportError();
return 1;
}
I am looking at passing a variable as the first argument to the CFile::Open() method.
The ## operator is a preprocessor concatenation operator. That is, this is valid code:
In your case, the
_Tmacro prepends the Long conversion symbol (L) to the input given. This only works with string literals. That means you can’t writebut you can safely write
The
Loperator is a convertor of char and char* literals to a Long representation (frombyte-wide representation tosizeof(wchar_t)-wide representation).