Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::wstring, TCHAR, wchar_t and LPTSTR

Reply
Thread Tools

std::wstring, TCHAR, wchar_t and LPTSTR

 
 
sorty
Guest
Posts: n/a
 
      11-24-2003
Hi,

I have read in many places that TCHAR can be 'char' or 'wchar_t'
depending on ANSI or UNICODE.

I have also read that LPTSTR is a long pointer to a TCHAR.

I am confused about the following. Please answer with yes/no and then
elaborate as you please..

1. Where is TCHAR, LPTSTR defined

2. Is TCHAR for MFC apps only? Can I use it in a standard console app?

3. Is LPTSTR for MFC apps only? Can I use it in a standard console
app?

4. Is TCHAR and LPTSTR portable to other platforms such as UNIX?

5. Why would I use LPTSTR when I can just use a pointer to TCHAR eg
TCHAR *ch[]
 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      11-24-2003

"sorty" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) om...

> I have read in many places that TCHAR can be 'char' or 'wchar_t'
> depending on ANSI or UNICODE.


You need to discuss this on a group with microsoft in it's name, but the
above is correct.

> I have also read that LPTSTR is a long pointer to a TCHAR.


It's not a long pointer to anything (damed MS stupidity). It's TCHAR*.


 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      11-24-2003
Ron Natalie wrote:
> "sorty" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) om...
>
>
>>I have read in many places that TCHAR can be 'char' or 'wchar_t'
>>depending on ANSI or UNICODE.

>
>
> You need to discuss this on a group with microsoft in it's name, but the
> above is correct.
>
>
>>I have also read that LPTSTR is a long pointer to a TCHAR.

>
>
> It's not a long pointer to anything (damed MS stupidity). It's TCHAR*.



I suspect you mean "damned". If it was truly damed I don't think we
would care so much


 
Reply With Quote
 
Bob Hairgrove
Guest
Posts: n/a
 
      11-24-2003
On 24 Nov 2003 08:49:30 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) (sorty) wrote:

>Hi,
>
>I have read in many places that TCHAR can be 'char' or 'wchar_t'
>depending on ANSI or UNICODE.


TCHAR is a Windows macro ... use std::_TCHAR instead which is defined
in <tchar> or <tchar.h>.

>I have also read that LPTSTR is a long pointer to a TCHAR.
>I am confused about the following. Please answer with yes/no and then
>elaborate as you please..
>
>1. Where is TCHAR, LPTSTR defined



LPTSTR and TCHAR are defined somewhere in the Windows header files.

>
>2. Is TCHAR for MFC apps only? Can I use it in a standard console app?


You can use it anywhere as long as you include the header file(s)
where it is defined. It is not specific to MFC.

>3. Is LPTSTR for MFC apps only? Can I use it in a standard console
>app?


Same as above.

>4. Is TCHAR and LPTSTR portable to other platforms such as UNIX?


No. Use _TCHAR and _TCHAR* instead.

>5. Why would I use LPTSTR when I can just use a pointer to TCHAR eg
>TCHAR *ch[]


All over the Windows API functions are declared this way. Who knows
whether someday they will be defined differently? Using the same
macros -- distasteful as they may be -- would keep your code from
breaking if they were ever redefined.



--
Bob Hairgrove
(E-Mail Removed)
 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      11-25-2003
Bob Hairgrove wrote:

> On 24 Nov 2003 08:49:30 -0800, (E-Mail Removed) (sorty) wrote:
>
>>Hi,
>>
>>I have read in many places that TCHAR can be 'char' or 'wchar_t'
>>depending on ANSI or UNICODE.

>
> TCHAR is a Windows macro ... use std::_TCHAR instead which is defined
> in <tchar> or <tchar.h>.


Still Windows specific though. Btw, wtf does it do in the std namespace?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting from windows wchar_t to linux wchar_t yakir22@gmail.com C++ 3 08-15-2008 09:04 AM
LPTSTR to char *.. How free2cric C++ 3 02-20-2005 02:34 PM
LPTSTR to char *.. How free2cric C Programming 3 02-19-2005 05:59 PM
LPTSTR initialization alex C++ 9 06-24-2004 01:56 AM
string class that can convert between wchar_t and char Bren C++ 4 10-07-2003 03:24 PM



Advertisments