|
Parthi_Appu wrote: _T("sometext") means, sometext will be treated as ANSI and if _UNICODE is defined
hey, here is how the macro is defined :
#if defined(UNICODE)
#define _T(x) L##x
#else
#define _T(x) x
#endif
so if you don't define unicode, the string will remain ansi (so, not neither LPWSTR nor LPTSTR but LPSTR !!!)
|
|
|
|
|
Tox, but _UNICODE explicitly defines UNICODE . I was insisting on that person telling that you will never need to typecast.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
brahmma wrote: ..._UNICODE explicitly defines UNICODE.
No, you have to define them both.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: No, you have to define them both.
Either you are wrong. Or Jeff Prosise is wrong in the book, Programming Windows with MFC, Second edition.
Programminw Windows with MFC, Second edition - Jeff Prosise wrote:
If all your string literals are declared with _T macros, you can produce a special Windows NT_only build of your application by defining _UNICODE. Defining this symbol (_UNICODE symbol) implicitly defines a related symbol named UNICODE (no underscore), which selects the Unicode versions of the numerous Windows API functions that come in both ANSI and Unicode versions.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
brahmma wrote: Either you are wrong. Or Jeff Prosise is wrong in the book, Programming Windows with MFC, Second edition.
Rather than read a book or take someone's word for it, did you bother to try it? The presence of:
#define _UNICODE does not automatically tell the preprocessor to also define the other:
#define UNICODE
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have seen the definition too, clearly but I do not remember the file name. I checked it for myself when I read that in the book, about an year ago. The definition for _UNICODE goes something like this:
#ifndef UNICODE
#define UNICODE
....
#endif
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Are you thinking of something along the lines of:
#ifdef _UNICODE
#ifndef UNICODE
#define UNICODE
#endif
#endif or
#if defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#endif
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Not the second one, for sure. I am not on my dev. machine now and am unsure of the file name. I am talking about how _UNICODE is defined. In the definition, a check for UNICODE inclusion is present and if UNICODE is not included, it is done there explicitly. I shall find out the file name and then give you the code clearly, which I was talking about.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
brahmma wrote: In the definition, a check for UNICODE inclusion is present and if UNICODE is not included, it is done there explicitly.
Right, but not implicitly by the preprocessor.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
maybe depends on where the #define _UNICODE is done... it probably tells automaticallty to define UNICODE (without _ ) if it is set in the compiler's command line parameters.
BTW, i never understood why microsoft had to bother with several variants of the quite same macros... why not having a single UNICODE macro used everywhere ?
i also noticed somewhere that the actual definition of _T() macro was : #define _T __T
where the f*ck is the reason behind this ?
|
|
|
|
|
toxcct wrote: BTW, i never understood why microsoft had to bother with several variants of the quite same macros... why not having a single UNICODE macro used everywhere ?
UNICODE macro is for calling the unicode version of various Win32 APIs and _UNICODE is similar for calling the unicode version of MFC functions.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
brahmma wrote: ...and _UNICODE is similar for calling the unicode version of MFC functions.
More specifically, _UNICODE is for CRT functions.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
toxcct wrote: maybe depends on where the #define _UNICODE is done...
Exactly. It only happens in a few select situations (e.g., performance counters, ATL, MFC), and only because a certain header file was included, not because the preprocessor does it automatically.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Parthi_Appu wrote: Simply, _T("sometext") means, sometext will be treated as ANSI and if _UNICODE is defined, then, sometext will be converted to
Dude, I am amazed to see your reply. How do you think this can be even possible?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
abracadabraaaa ding !
oh, a rabbit !
|
|
|
|
|
brahmma wrote: How do you think this can be even possible
What made you think that it is impossible?..
Do your Duty and Don't expect the Result
|
|
|
|
|
Read this[^].
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Yeah thats what i mentioned.
toxcct posted its definition.. thats it..
what difference you see between my post and toxcct's post..
Do your Duty and Don't expect the Result
|
|
|
|
|
You said you will never need a typecast, which thrills me.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
I think you misunderstood my reply...
I mentioned that sentence, for the parameter to CreateFile API...
to represent a file name.. thats it...
I didn't say that, we never need a typecast..
Do your Duty and Don't expect the Result
|
|
|
|
|
Sorry, I get you now. Never mind.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Hey no prob..
Do your Duty and Don't expect the Result
|
|
|
|
|
Hi toxcct,
Sorry i'm not clearly read your post.
To make the string always UNICODE we have to use L or someother converting macro.
Sorry once again...
Do your Duty and Don't expect the Result
|
|
|
|
|
ok nevermind
|
|
|
|
|
toxcct wrote: why not using C++ cast operators ?!
Problem was not related to this, just ignored that.
toxcct wrote: Notice that those 2 lines of code are quite the same, because is unicode is not defined, _T() simply equals its content (just removed)...
OP is facing problem because, UNICODE is defined. Otherwise, he would not have needed to use LPCWSTR .
toxcct wrote: Here[^] is a link to those macros
Thanks for this.
|
|
|
|