Solved

Unable to compile in Unicode

Posted on 2004-10-05
4
597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 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