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"
What is possible to do ?
First off, the name '_Text' is reserved by the implementation. Do *not*
under any circumstances name your variables/functions starting with an
underscore and a capital letter. That aside...
You cannot expect to define some mechanism that would somehow tweak your
source code and hope for it *not* to be a macro. That's the point. It
has to be a macro to squeeze the 'L' in front of the literal before the
compiler gets its hands on the code.
What is it you're trying to accomplish?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
> #define _T(x) __TEXT(x)
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...@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