James Kanze
10/30/2008 9:51:00 AM
On Oct 29, 5:25 pm, John Doe <mos...@anonymous.org> wrote:
> I would like to know if it would be possible to replace _T()
> macros used on windows to delcare an ANSI string or a unicode
> one :
> #ifdef UNICODE
> #define __TEXT(quote) L##quote // r_winnt
> #else
> #define __TEXT(quote) ##quote
> #endif
> #define _T(x) __TEXT(x)
> I was thinking of something like
> _Text<char>("some text") that would return "some text"
> and
> _Text<wchar_t>("some text") that would return L"some text"
The obvious first answer is that the above is impossible, since
the arguments to a macro have to be in the parentheses.
The obvious second answer is that it is trivial to write a small
preprocessor which does this; probably around a hundred lines of
code, in all (using flex and a simple state machine).
A less obvious third answer is that it doesn't buy you anything.
The way you process wide characters is different than what you
do with narrow characters; just changing char to wchar_t and
"..." to L"..." won't produce anything usable.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34