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??

10 Years
Discussion Span
Last Post by Ancient Dragon

try doing a reinterpret cast

reinterpret_cast<new data type> (expression to convert)

or you may have some data wrong


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().

Votes + Comments
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.