A couple of days ago I wrote a simple function and a part of it looked like this:
CString str;
str.Format(_T("this is only a test"));
int idx = str.Find('o');
if( idx >= 0 )
str = str.Left(idx);
The project have UNICODE defined so when today I reviewed this piece of code it looked wrong because the Find method as a character parameter that is not treated really as an unicode character. However it did compile well (and work too) under Visual C++ 6.
So when I got home I decided I need to understand why it works. I opened my Microsoft Visual C++ .NET 2003 wrote this little test console app and I generated the asm and the results (in debug configuration) are:
; 22 : int idx = str.Find('o'); |
; 22 : int idx = str.Find(_T('o')); |
So both of them are compiled in the same manner. That's explain why it did compile successfully and why it works but I still doesn't understand why it didn't require the L (or TEXT or _T) macro.
No comments:
Post a Comment