954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

type conversion error

hi,

i m building the code in VC++6.0. (win32 unicode debug)
i m getting the following error in the RPC call
error C2664: 'UuidToStringW' : cannot convert parameter 2 from 'unsigned char ** ' to 'unsigned short ** '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

the code snippet is
UUID * pUuid;
UCHAR * pszUuid;
SafeArrayAccessData (vtId.parray, (void **)&pUuid);
UuidToString (pUuid, &pszUuid);

what is the reason and how can it be resolved??

m_meena
Newbie Poster
16 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

try doing a reinterpret cast

reinterpret_cast (expression to convert)

or you may have some data wrong

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

The function that is being called requires wchar_t* instead of char* when compiling a program for UNICODE. Typecasting will not make the conversion. Instead you should be using the macros provided in tchar.h to make the conversion. when compiling for UNICODE all character string literals need to be surrounded with either _T( "string literal here" ) or _TEXT("string literal"); Character arrays need to be declared with TCHAR macro instead of char* ( or UCHAR* in your code snipped), for example TCHAR* buffer . All the string manipulation functions in string.h also have UNICODE equivalents and you should use the portable UNICODE version as shown in MSDN, such as _tcscpy() instead of strcpy().

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You