Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

widestring to wchar_t bcb6 to BDS2006

314 views
Skip to first unread message

John Mc

unread,
Jul 25, 2008, 2:57:26 PM7/25/08
to
I have some code that looks something like this:

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

Remy Lebeau (TeamB)

unread,
Jul 25, 2008, 3:01:36 PM7/25/08
to

"John Mc" <don't spam me> wrote in message
news:488a2215$1...@newsgroups.borland.com...

> 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


Darko Miletic

unread,
Jul 25, 2008, 3:24:06 PM7/25/08
to
John Mc wrote:
> I have some code that looks something like this:
>
> 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:

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);
}

0 new messages