Hello
I am trying to convert the following???
The Code
std::string* ChkName;
GlobalInterface Ptr->MethodA(po*sit ion, bstr, ChkName);
error C2664: 'MethodA' : cannot convert parameter 3 from 'class
std::basic_stri ng<char,struct std::char_trait s<char>,class
std::allocator< char> > ** ' to 'unsigned short ** '
Could anyone give me suggestions?
Thanks!
Karthik 7 10267
"Karthik" <ka*******@gmai l.com> wrote in message std::string* ChkName; GlobalInterface Ptr->MethodA(po-sition, bstr, ChkName);
error C2664: 'MethodA' : cannot convert parameter 3 from 'class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > ** ' to 'unsigned short ** '
Could anyone give me suggestions?
What are you trying to do?
You're passing a std::string* to a function that's apparently expecting an
unsigned short**. Why are you doing that? What exactly are you trying to
accomplish?
(Also, what's "po-sition"? Are you subtracting "sition" from "po"?)
-Howard
Karthik wrote: I am trying to convert the following???
The Code
std::string* ChkName;
GlobalInterface Ptr->MethodA(po*sit ion, bstr, ChkName);
error C2664: 'MethodA' : cannot convert parameter 3 from 'class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > ** ' to 'unsigned short ** '
Could anyone give me suggestions?
Not really. You are not even posting the real code, which probably
looks like
GlobalInterface Ptr->MethodA(positi on, bstr, &ChkName)
.. Now, apparently 'MethodA' has the third argument declared as
a pointer to a pointer to 'unsigned short', and you're sticking the
address of a pointer to 'std::string' there. WHY? Who knows... How
to fix it? Who knows... Post more code.
V
Karthik wrote: I am trying to convert the following???
std::string* ChkName;
Are you *really* sure you want a pointer to a string?
GlobalInterface Ptr->MethodA(po*sit ion, bstr, ChkName);
error C2664: 'MethodA' : cannot convert parameter 3 from 'class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> > ** ' to 'unsigned short ** '
Could anyone give me suggestions?
It looks like you're using VC6 where wchar_t is a typedef for unsigned
short instead its own distinct type and the 3rd parameter for MethodA
is a wchar_t ** for some really stupid reason. Try this code instead:
std::wstring ChkName;
....
wchar_t *str = const_cast<wcha r_t*>(ChkName.c _str());
GlobalInterface Ptr->MethodA(positi on, bstr, &ChkName);
Though this looks like a hack to work around a poorly defined member
function and evidence to consider something is wrong with the code
you're using.
Quoting ME <ant_sp...@Y... .com>:
It looks like you're using VC6 where wchar_t is a typedef for unsigned
short instead its own distinct type and the 3rd parameter for MethodA
is a wchar_t ** for some really stupid reason.
Yes I am using VC++ 6.0. Please do see the code
Quoting ALL:
Alrt.. I am pasting the code of what I am doing... And Yes I need to
pass a BSTR value in the place of the third parameter
BEGIN_RULE_FUNC TION(rule_ONE_S chedule)
{
FIString batchName, lotStepName, lotName, stepName;
FIString remainingTaskNa me = "";
std::string* ChkName;
int position; //using it as an indexer....
char* StationName = new char[10];
// Copy text in the attribute
strcpy (StationName, theStation->name().data()) ;
wchar_t wstr[256];
// Transform the text in the COM format
MultiByteToWide Char (CP_ACP, 0, StationName, -1, wstr, sizeof(wstr) /
sizeof (wchar_t));
// Format for the communication, and memory allocation
BSTR bstr = SysAllocString (wstr);
WCHAR ws[256];
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS, taskName->c_str, -1,
ws, sizeof(ws) / 2 - 1);
BSTR tName = SysAllocString (ws);
GlobalInterface Ptr->MethodA(positi on, bstr, &tName);
while ((tName != NULL))
{
batchName = tName->c_str();
rescueBatchName = tName->c_str();
//some other code.....
}
}
What this code does is... Passes the parameters to the Function written
in C# and gets a string value in return, the parameter "tName"
mentioned in the GlobalInterface Ptr->MethodA(...... .).. and checks the
value in side the tName and goes into the "While" loop...
Does this help to provide a lead?
The error I get is
error C2664: 'MultiByteToWid eChar' : cannot convert parameter 3 from
'const char *(void) const' to 'const char *'
There is no context in which this conversion is possible
Any thoughts???
Thanks a much!
Karthik
"Karthik" <ka*******@gmai l.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Quoting ME <ant_sp...@Y... .com>:
Alrt.. I am pasting the code of what I am doing... And Yes I need to pass a BSTR value in the place of the third parameter
I have no idea what a "BSTR" is. I assume your'e talking about some
Microsoft-defined type? It has nothing to do withe the error, though. (see
below)
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS, taskName->c_str, -1, ws, sizeof(ws) / 2 - 1);
The error I get is
error C2664: 'MultiByteToWid eChar' : cannot convert parameter 3 from 'const char *(void) const' to 'const char *' There is no context in which this conversion is possible
Any thoughts???
This is different from what you posted before.
The error message says it can't convert from a function: "const char *(void)
const" to a pointer: "'const char *".
The problem is that you're passing taskName->c_str to the function. But
c_str is a function, not a variable. You're passing the address of that
function, when you need to pass the _results_ of that function call, by
adding the parentheses. It should be:
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS,
taskName->c_str(), // note the parentheses!
-1, ws, sizeof(ws) / 2 - 1);
There may be other errors, but that's the one the compiler's complaining
about.
-Howard
Karthik wrote: Quoting ME <ant_sp...@Y... .com>:
It looks like you're using VC6 where wchar_t is a typedef for unsigned short instead its own distinct type and the 3rd parameter for MethodA is a wchar_t ** for some really stupid reason.
Yes I am using VC++ 6.0. Please do see the code
Quoting ALL:
Alrt.. I am pasting the code of what I am doing... And Yes I need to pass a BSTR value in the place of the third parameter
BEGIN_RULE_FUNC TION(rule_ONE_S chedule) {
FIString batchName, lotStepName, lotName, stepName;
FIString remainingTaskNa me = "";
std::string* ChkName;
int position; //using it as an indexer.... char* StationName = new char[10];
// Copy text in the attribute strcpy (StationName, theStation->name().data()) ;
wchar_t wstr[256];
// Transform the text in the COM format MultiByteToWide Char (CP_ACP, 0, StationName, -1, wstr, sizeof(wstr) / sizeof (wchar_t));
// Format for the communication, and memory allocation BSTR bstr = SysAllocString (wstr);
WCHAR ws[256];
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS, taskName->c_str, -1, ws, sizeof(ws) / 2 - 1);
BSTR tName = SysAllocString (ws);
GlobalInterface Ptr->MethodA(positi on, bstr, &tName);
while ((tName != NULL)) { batchName = tName->c_str();
rescueBatchName = tName->c_str();
//some other code.....
} }
What this code does is... Passes the parameters to the Function written in C# and gets a string value in return, the parameter "tName" mentioned in the GlobalInterface Ptr->MethodA(...... .).. and checks the value in side the tName and goes into the "While" loop...
Does this help to provide a lead?
The error I get is
error C2664: 'MultiByteToWid eChar' : cannot convert parameter 3 from 'const char *(void) const' to 'const char *' There is no context in which this conversion is possible
Any thoughts???
Thanks a much!
Karthik
You have this:
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS, taskName->c_str,
-1, ws, sizeof(ws) / 2 - 1);
Did you mean for it to be this?
MultiByteToWide Char(CP_ACP, MB_ERR_INVALID_ CHARS, taskName->c_str(),
-1, ws, sizeof(ws) / 2 - 1);
i.e. change "parameter 3" from
taskName->c_str
to
taskName->c_str()
Regards,
Larry
Hey Larry and all...
Thanks a million... I was able to solve the bug.. yeah I missed the '(
)' in c_str...
Thanks a much!
Karthik This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: c++newbie |
last post by:
Hi all,
I try to compile the following classes:
main.cpp:
#include <algorithm>
#include <iostream>
#include <fstream>
#include <iterator>
|
by: yanyo |
last post by:
hi, im trying to figure out whats the problem with this program i get a
runtime error but i dont see where the problem is i tried changing
declaration but nothing if somrbody can try this on their compiler to make
sure is not a compiler compatibility problem.
#include<stdio.h>
#include<math.h>
char menu_action(void);
|
by: karthik.t |
last post by:
Hello
I am trying to convert the following???
The Code
std::string* ChkName;
GlobalInterfacePtr->MethodA(position, bstr, ChkName);
|
by: Shawn |
last post by:
JIT Debugging failed with the following error: Access is denied.
JIT Debugging was initiated by the following account 'PLISKEN\ASPNET'
I get this messag in a dialog window when I try to open an asp.net page. If
I press OK then I get a page with this message:
Server Application Unavailable
The web application you are attempting to access on this web server is
currently unavailable. Please hit the "Refresh" button in your web browser...
|
by: linq936 |
last post by:
Hi,
I have this piece code,
struct TriStr {
MyString str1;
MyString str2;
MyString str3;
TriStr(MyString s1, MyString s2, MyString s3){
this->str1 = s1;
| |
by: stillh2os |
last post by:
Hello.
I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code will call. I'm getting Error 2664: cannot convert parameter 1 from CallBack __gc * to CUSTOM_HOOK_CALLBACK_FUNCTION. Here's what I have...
In my unmanaged DLL -- Header file:
---------------------------------------------------
typedef VOID...
|
by: Trent |
last post by:
Here is the error while using Visual Studio 2005
Error 1 error LNK2019: unresolved external symbol "void __cdecl
print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced
in function _main assign2.obj
Thanks a lot !
Here is the code:
|
by: misu101 |
last post by:
Hi,
I have a VS 6 project and I am trying to compile it using VS 2005.
My program has the atlbase.h include which seems to trigger the errors.
It used to compile OK using VS 6.
The include path is:
C:/Program Files/Microsoft Visual Studio 8/VC/include;C:/Program Files/Microsoft Visual Studio 8/VC/atlmfc/include;C:/Program Files/Microsof
t Visual Studio 8/SDK/v2.0/include;C:/Program Files/Microsoft Visual Studio...
|
by: Yoav |
last post by:
Hello,
I have been trying to enter SQL statmenbts to DB2 control center command line.
I saw that user "Thames" wrote to you:
> I have to repost my question for help.
>
> Yesterday I set up two DB UDB ESE V8.2 server on linux and windows
> platform, respectively. Both servers have been connected without any
> problems
> However, It gave me such error when I tried to make db connection via
> command prompt(windows)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |