Solved

Unable to compile in Unicode

Posted on 2004-10-05
4
591 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now