Re: Are _T() and TEXT() macros equivalent?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mon, 16 Apr 2007 10:15:58 -0700, "Tom Serface"
<tom.nospam@xxxxxxxxxxxxx> wrote:

It will mean that the variable holds a character (whatever that is depending
on the compile guidelines).

But we can already achieve that with TCHAR. Is it really so bad? I think it
would be bad for the meaning of a built-in type to be context-dependent in
this way. For example, consider a function like GetProcAddress. It's
defined in terms of LPCSTR, which indicates that even in Unicode builds,
it's still ANSI. With the meaning of char dependent on the capriciousness
of a switch, you couldn't use char in this way, even though the function
takes a string. I guess you'd use the new type 'byte", but that doesn't
convey the idea of "string" very well. Or maybe you'd invent a set of
macros akin to the current TCHAR family just so you can use char as you
once did. And if you did implement the /unicode switch, you'd have to cater
to the Unix crowd, and some of their compilers implement wchar_t as UCS-4.
So now you'd have sizeof(char) == 4, which is almost certainly >
sizeof(short), which violates another fundamental C and C++ rule, that
sizeof(char) <= sizeof(short). I guarantee you that the more an expert
thinks about this proposed change, the more problems and ripple effects he
will find, and this will go on for quite a while. It ain't a simple thing
to do.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: StringCchCopy question
    ... Here you use the type defined as CHAR ... AND the constant string is defined as "PM_REMOVE" which ... CHAR and TCHAR are different you are in big trouble. ... properly in the use of a programming language; it is obvious by inspection that this can ...
    (microsoft.public.vc.mfc)
  • Re: help needed regarding compiling 2 C files
    ... How to compile two .C files at once? ... In my program I am tring to fetch one string from the array "cmdbuffer ... int main(int argc,char *argv) ...
    (comp.lang.c)
  • Re: How to convert TCHAR type to standard ISO C++ string?
    ... TCHAR s; ... if I compile it with the additional lines: ... string of about 40 characters as the printfdoes. ... but I must have it in order for the MS routine to work. ...
    (microsoft.public.vc.language)
  • Re: Newbie Q - Numberfmt not display number
    ... I think this shouldn't compile. ... CRect m_rectangle; ... Use a debugger to look at the string or use OutputDebugStringor the ... TCHAR based) which might lead to these errors. ...
    (microsoft.public.vc.language)
  • Re: Using VC6 code in VS 2005
    ... Both are char strings, no? ... LPTSTR is equivalent to TCHAR *. ... basing on the value of UNICODE and _UNICODE preprocessor macros. ... atoi wants a char* string, but CString::GetBuffer returns a TCHAR string. ...
    (microsoft.public.vc.language)