Re: Are _T() and TEXT() macros equivalent?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 09 Apr 2007 21:48:32 -0400
Remember that billions of lines of code existed in the C language before anyone thought of
supporting Unicode. If you start arguing that C ought to have these functions, that's
fine, but unfortunately, it didn't, and doesn't, and all of that code would break.
Furthermore, code written that would compile and run with the Unicode option enabled in
this way would break horribly if compiled with the ANSI option. So instead the programmer
is required to make the decisions, which means the programmer is claiming to be aware of
the implications of the changes in representation.
joe
On Mon, 9 Apr 2007 17:30:20 -0700, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in messageJoseph M. Newcomer [MVP]
news:1skl13578pilh48i5bb493mqddpclh9fn1@xxxxxxxxxx
That was my point; if you define 'char' to be Unicode, it violates
sizeof(char) premises
that are wired deeply into a lot of programs. The resulting chaos of
changing 'char' such
that sizeof(char) == 2 would be disastrous. Think of all the places where
in doing
Unicode we have to *sizeof(TCHAR) or /sizeof(TCHAR).
It seems to me the reason sizeof(char) == 1 is "wired deeply into" a lot of
programs is to workaround the lack of something like _cb() and _cch()
reserved words which would return the number of bytes and the number of
chars, respectively, in the variable passed in as the parameter. Had these
been available, people would have used them instead of sizeof(char) and it
would be a piece of cake to
#define char wchar_t
and have it just work.
I would say the correct behavior at this point is to introduce these
concepts now and let the programmer beware that using them sporadically in
existing codebases may not work. That's no different than giving both
release and debug builds of DLL's and not supporting them being mixed and
matched.
But instead, the standard insists on preserving some ancient rule that says
sizeof(char) == 1, and we all have to suffer the shortcomings (e.g. using
_T()) forever and ever. For reasons I don't understand or appreciate.
-- David
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Are _T() and TEXT() macros equivalent?
- From: David Ching
- Re: Are _T() and TEXT() macros equivalent?
- References:
- Re: Are _T() and TEXT() macros equivalent?
- From: MrAsm
- Re: Are _T() and TEXT() macros equivalent?
- From: David Ching
- Re: Are _T() and TEXT() macros equivalent?
- From: Mihai N.
- Re: Are _T() and TEXT() macros equivalent?
- From: David Ching
- Re: Are _T() and TEXT() macros equivalent?
- From: Mihai N.
- Re: Are _T() and TEXT() macros equivalent?
- From: David Ching
- Re: Are _T() and TEXT() macros equivalent?
- From: Joseph M . Newcomer
- Re: Are _T() and TEXT() macros equivalent?
- From: Doug Harrison [MVP]
- Re: Are _T() and TEXT() macros equivalent?
- From: Joseph M . Newcomer
- Re: Are _T() and TEXT() macros equivalent?
- From: David Ching
- Re: Are _T() and TEXT() macros equivalent?
- Prev by Date: Re: How many bytes per Italian character?
- Next by Date: what's the differences?
- Previous by thread: Re: Are _T() and TEXT() macros equivalent?
- Next by thread: Re: Are _T() and TEXT() macros equivalent?
- Index(es):
Relevant Pages
|