Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

how to use tchar

I've tried to look at the msdn articles to use the tchar variable, to no avail. I'm trying to use it to hold the string that is returned from a function builtin to windows. Because I'm including afxinet.h, I can't include windows.h, and I tried to include tchar.h and Im still coming up with compiler error #C2143, and #C2065. These are because the compiler is not finding the type - tchar.

TIA
[426 byte] By [tody4] at [2007-11-11 7:52:42]
# 1 Re: how to use tchar
If you need to get done now, try to fool the compiler -- typedef up a tchar (its 8 or 16 bit ints depending on your unicode settings, default is 8 I think) and see if you can get past this.

In the long term, you will want to re-make the project file and try to get it configured correctly so that you can simply use the window's one. Your project settings are hosed up, possibly beyond repair.
jonnin at 2007-11-11 21:01:49 >
# 2 Re: how to use tchar
Just curious but did you included the 'tchar.h' file?

The tchar.h file contains macros that help with creating a single source file that can be the used in projects that need to support both unicode and single, multi-byte builds. Search the MSDN for this artical, 'Generic-Text Mappings in TCHAR.H'.

Cheers,
Mike
marsigme at 2007-11-11 21:02:44 >
# 3 Re: how to use tchar
Thanks mike. I got it working, I tried to include tchar.h, no difference, tried include windows.h, got windows.h could not be included in a mfc project, come to find out that I had the array dec wrong.
tody4 at 2007-11-11 21:03:49 >