AnsiString strName;
WideString nameWideStr;
// some code to build strName
ThirdPartyFunc1(nameWideStr);
This has worked nicely under BCB 6. Now I am trying to compile the code
under BDS2006 and get the following errors:
[C++ Error] GEMUtils.cpp(83): E2034 Cannot convert 'WideString' to 'wchar_t
*'
[C++ Error] GEMUtils.cpp(83): E2342 Type mismatch in parameter 'name'
(wanted 'wchar_t *', got 'WideString')
What do I have to do to get this to work under BDS2006?
Thanks in advance for your help.
J
> This has worked nicely under BCB 6. Now I am trying to
> compile the code under BDS2006 and get the following errors:
>
> [C++ Error] GEMUtils.cpp(83): E2034 Cannot convert 'WideString' to
> 'wchar_t
> *'
That should be working fine. WideString has a BSTR conversion operator
defined, and BSTR is a typedef for wchar_t*.
> [C++ Error] GEMUtils.cpp(83): E2342 Type mismatch in parameter
> 'name' (wanted 'wchar_t *', got 'WideString')
>
> What do I have to do to get this to work under BDS2006?
If the conversion operator is not working properly, you can call the
WideString::c_bstr() method explicitally:
ThirdPartyFunc1(nameWideStr.c_bstr());
Gambit
I am unable to reproduce your error. Can you send some code that
reproduces this error?
Here is my example (which compiles without any error) :
void myfunc(wchar_t *pp) {
(pp);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString ws(L"aaa");
myfunc(ws);
}