Solved

Unable to compile in Unicode

Posted on 2004-10-05
4
593 Views
Last Modified: 2007-12-19
I am working on a vc++ application which compiles in  debug mode & release mode the application compiles well but when the configuration changed to unicode debug the lot of errors occured like following

 error C2664: 'RegCreateKeyW' : cannot convert parameter 2 from 'char [256]' to 'const unsigned short *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

error C2664: 'wcsncpy' : cannot convert parameter 2 from 'char *' to 'const unsigned short *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

error C2664: 'strcpy' : cannot convert parameter 2 from 'const unsigned short *' to 'const char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

  what should the setting for unicode debug & release

Help Very Urgent

0
Comment
Question by:leork2004
4 Comments
 
LVL 11

Expert Comment

by:dimitry
ID: 12226974
You need to add to defines section of the project next defines:
_UNICODE, UNICODE
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 12227143
All string constant should have prefix _T, all stings should be of type TCHAR* and not char*. Read this article:

http://www.codeproject.com/cpp/unicode.asp
0
 
LVL 86

Expert Comment

by:jkr
ID: 12228197
Actually, it is not a 'prefix _T', but you have to embed them in a macro , e.g.

TCHAR* test=_T("TEST");
0
 
LVL 30

Expert Comment

by:Axter
ID: 12231582
FYI:
You can use PTCHAR instead of TCHAR*

PTCHAR test=_T("TEST");

Also, don't forget to use _tcs??? string functions instead of str functions.
_tcscat  
_tcschr  
_tcscpy  
_tcscspn  
_tcslen  
_tcsncat  
_tcsncpy  
_tcspbrk  
_tcsrchr  
_tcsspn  
_tcsstr  
_tcstok  
_tcsdup  
_tcsnset  
_tcsrev  
_tcsset  
_tcscmp  
_tcsicmp  
_tcsnccmp
_tcsncmp  
_tcsncicmp
_tcsnicmp
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question