[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Replace _T() macros

John Doe

10/29/2008 4:25:00 PM

Hi,

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 ?


3 Answers

Victor Bazarov

10/29/2008 5:04:00 PM

0

John Doe wrote:
> Hi,
>
> 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

James Kanze

10/30/2008 9:51:00 AM

0

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

Dave Kelly

11/17/2011 4:35:00 PM

0


"yoker" <yoker56@yahoo.com> yolked in message

> Is the relatively inexpensive Experience version with 2 discs or the
> expensive Immersion version with 5 discs CD/DVD-A/3-D Blu-Ray?

How can ya put a price on music this classic?