Solved

Unable to compile in Unicode

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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 learn how to clear a vector as well as how to detect empty vectors in C++.

636 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