Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#define _WIN32_WINNT 0x0500 //for define Character Sets ID

#include "windows.h"
#include "string.h"
#include "stdio.h"
#include "locale.h"
#include "tchar.h"

//set windows code page 1252 Latin1 for TextOutA
_tsetlocale (LC_ALL, _TEXT ("german_germany.1252")) ;


When I compile , I got an Error from cl.exe (VC++ 6.0 / windowsXP sp2)

it says _tsetlocale is undefined.

I also tried other all the TCHAR.h routine (_tcsclen and so on)

but it still gives me the same error.

I wish someone could tell me Where is wrong ?
Posted
Updated 13-Jan-11 0:05am
v5
Comments
Richard MacCutchan 13-Jan-11 6:55am    
I do not see what is different in your solution to what you have coded in your original question. What has changed?

There does not appear to be a definition for _tsetlocale, see here[^] for the available options.
 
Share this answer
 
Comments
tanakahitori 13-Jan-11 5:44am    
I really found _tsetlocale is defined in my TCHAR.h
/ I opened tchar.h with notepad.exe , Ctrl+F to find "_tsetlocale"

#define _tsetlocale _wsetlocale /for WCHAR
#define _tsetlocale setlocale /for CHAR

/ and I am sure my VC++6.0 include Directory path is right , because other head-files works

I dont understand why I got this Error

and all other TCHAR string routine (_tcsclen, _tcscpy, _tcscat) gets undefined-error too,
but they are defined in TCHAR.h
tanakahitori 13-Jan-11 6:49am    
I fixed this error,

because I only write "_tsetlocale" in source.
and selected it ,
right-click to choose "Go To Definition of _tsetlocale"
and I got this error "undefined" from VC++6.0

I shouled write full function like this
"_tsetlocale (LC_ALL, _TEXT ("german_germany.1252")) ;"
When I try your code (VC++ 6, WinXP sp3), it compiles just fine. What is the exact wording of the error?

error LNK2001: unresolved external symbol _setlocale would indicate you didn't link a C run time library[^].

error C2065: '_tsetlocale' : undeclared identifier would imply the #define hasn't been read. One possibility I could think of that would cause this is that the wrong TChar.h has been read. You use a quoted include rather than an angle-bracket include, which means it first scans your project directory before searching in the compiler's include path.
You could try hardcoding the path in the #include to eliminate this possibility;
#include "C:/Program Files/Microsoft Visual Studio/VC98/Include/TChar.h"
 
Share this answer
 
v3
Comments
Richard MacCutchan 13-Jan-11 9:18am    
I'm also confused about what was changed, and the OP's explanation about why it now compiles. Probably another of those mysteries of the universe.
tanakahitori 13-Jan-11 12:14pm    
I think problem is not include path of head-file.

My VC++6.0 is installed at E:

[Tools] - [Options] - [Directories] - [Show directories for] -> (include files)

E:\Microsoft Visual Studio\VC98\INCLUDE (where the Tchar.h is)

I never changed this setting and path of VC6 since I installed VC6.0

whatever quoted ("tchar.h") or angle-bracket () I use.

my source works very well now, which I writed in my question.

and sorry for my fool!

I cannt get that error-word back anymore. because I really cannt know what mistken I did, and I cannt remember what somethings I changed later.

but one thing I still remember, when I tested it first time,
I pasted only Function-name '_tsetlocale' in source without () and parameters and ';' .
and selected it , right-click to choose "Go To Definition of _tsetlocale".

it said: symbol '_tsetlocale' is undefined (I sure all headfiles was included at top.)

!now it works. (I just cannt remember what somethings I changed)

now I tried again, I did same as I did first time.
paste only a function-name '_tsetlocale' in source without parameters and () and ';'.
and selected it , right-click to choose "Go To Definition of _tsetlocale".

It could Go to where it is defined in TCHAR.H now

it is really miraculous.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900