Solved

Unable to compile in Unicode

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

837 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