I am having an issue with some VC++ I am writing. I have a struct and
I'm trying to call a function from it from a function in another
object.
here is the struct.... -
struct JNI_Interface
-
{
-
JavaVM *jvm; /* denotes a Java VM */
-
JNIEnv *env; /* pointer to native method interface */
-
//static jobject phone_obj; // phone object to make JNI calls to PTF
-
with
-
-
int jni_startJVM();
-
int jni_checkException(char* jni_call) const;
-
int jni_startCom() const;
-
};
-
here are the function defs... -
JNI_Interface::jni_startCom() const
-
{
-
const char* phone_class_name = "phonetest/phone/synergy/SynergyPhone";
-
// class of phone to use
-
.....
-
}
-
here is the call... -
in mobilePhone class...
-
private:
-
JNI_Interface ptfPhone;
-
-
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // for testing
-
return 0;
-
-
}
-
I am getting this error...
[error]
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'const JNI_Interface &'
[/error]
all the other online research I've done told me that if I changed these
functions to const that would fix this issue, but it still remains.
Any ideas? 10 5898 do******@gmail. com wrote:
I am having an issue with some VC++ I am writing. I have a struct and
I'm trying to call a function from it from a function in another
object.
here is the struct.... -
struct JNI_Interface
-
{
-
JavaVM *jvm; /* denotes a Java VM */
-
JNIEnv *env; /* pointer to native method interface */
-
//static jobject phone_obj; // phone object to make JNI calls to PTF
-
with
-
int jni_startJVM();
-
int jni_checkException(char* jni_call) const;
-
int jni_startCom() const;
-
};
-
here are the function defs... -
JNI_Interface::jni_startCom() const
-
{
-
const char* phone_class_name = "phonetest/phone/synergy/SynergyPhone";
-
// class of phone to use
-
....
-
}
-
here is the call...
-
in mobilePhone class...
-
private:
-
JNI_Interface ptfPhone;
-
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // for testing
-
return 0;
-
}
-
I am getting this error...
[error]
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'const JNI_Interface &'
[/error]
all the other online research I've done told me that if I changed
these functions to const that would fix this issue, but it still
remains. Any ideas?
Not enough information. Which line in the posted fragments does
the error message refer to?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
The error is thrown on the call to jni_startCom(); -
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // THIS LINE THROWS THE
-
ERROR!!!
-
return 0;
-
-
}
-
do******@gmail. com wrote:
I am having an issue with some VC++ I am writing. I have a struct and
I'm trying to call a function from it from a function in another
object.
here is the struct.... -
struct JNI_Interface
-
{
-
JavaVM *jvm; /* denotes a Java VM */
-
JNIEnv *env; /* pointer to native method interface */
-
//static jobject phone_obj; // phone object to make JNI calls to PTF
-
with
-
int jni_startJVM();
-
int jni_checkException(char* jni_call) const;
-
int jni_startCom() const;
-
};
-
here are the function defs... -
JNI_Interface::jni_startCom() const
-
{
-
const char* phone_class_name = "phonetest/phone/synergy/SynergyPhone";
-
// class of phone to use
-
....
-
}
-
here is the call...
-
in mobilePhone class...
-
private:
-
JNI_Interface ptfPhone;
-
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // for testing
-
return 0;
-
}
-
I am getting this error...
[error]
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'const JNI_Interface &'
[/error]
all the other online research I've done told me that if I changed these
functions to const that would fix this issue, but it still remains.
Any ideas?
Firstly, which line of your code gives you this error exactly? You forgot to
indicate that.
Secondly, are you sure you reproduced the actual error message correctly?
Because frankly the way it looks in your message it doesn't make much sense
(could be VC++ compiler's fault, though).
--
Best regards,
Andrey Tarasevich do******@gmail. com wrote:
The error is thrown on the call to jni_startCom();
-
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // THIS LINE THROWS THE
-
ERROR!!!
-
return 0;
-
}
-
So, is 'ptfPhone' "const" or not? Is 'jni_startCom' member function
"const" or not? Read the FAQ 5.8 to understand why I am asking.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Victor Bazarov wrote:
do******@gmail. com wrote:
The error is thrown on the call to jni_startCom(); -
mobilePhone::com_startCom()
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // THIS LINE THROWS THE
-
ERROR!!!
-
return 0;
-
-
}
-
So, is 'ptfPhone' "const" or not? Is 'jni_startCom' member function
"const" or not? Read the FAQ 5.8 to understand why I am asking.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
I guess the struct and the member function don't need to be "const",
that was just one way of fixing the problem I was having that was
suggested elsewhere online. I took out the "const" from all of them.
Another thing I noticed is that in the output I'm getting this at my
error...
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'JNI_Interface &'
An object from the gc heap (member of a managed class) cannot
be converted to an non-gc reference
And I'm not sure what FAQ you are referring to.
<do******@gmail .comskrev i meddelandet
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
>
Victor Bazarov wrote:
>do******@gmail. com wrote:
The error is thrown on the call to jni_startCom();
-
mobilePhone::com_startCom()
-
-
Does this function have a return type?
-
-
-
-
-
{
-
// Added for JNI interface with PTF
-
if(comPort == "PTF")
-
{
-
int teh_test = ptfPhone.jni_startCom(); // THIS LINE THROWS THE
-
ERROR!!!
-
return 0;
-
}
-
-
-
-
-
>> So, is 'ptfPhone' "const" or not? Is 'jni_startCom' member function "const" or not? Read the FAQ 5.8 to understand why I am asking.
V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask
I guess the struct and the member function don't need to be "const",
that was just one way of fixing the problem I was having that was
suggested elsewhere online. I took out the "const" from all of
them.
Another thing I noticed is that in the output I'm getting this at my
error...
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'JNI_Interface &'
An object from the gc heap (member of a managed class) cannot
be converted to an non-gc reference
Are you compiling with the /clr switch set by any chance? If so, you
are using the language called C++/CLI, which is totally different.
Bo Persson do******@gmail. com wrote: -
JNI_Interface::jni_startCom() const
-
{
-
const char* phone_class_name = "phonetest/phone/synergy/SynergyPhone";
-
// class of phone to use
-
....
-
}
-
Any ideas?
You seem to have a syntax error in your code. "...." will not compile. do******@gmail. com wrote:
[error]
error C2662: 'JNI_Interface: :jni_startCom' : cannot convert 'this'
pointer from 'JNI_Interface' to 'const JNI_Interface &'
[/error]
Normally MSVC gives that error if you try to call a non-const function
using a const object. You're doing something like the below:
struct A {
int foo() const;
int bar();
};
void func() {
const A a1;
A a2;
a2.foo(); // ok
a2.bar(); // ok
a1.foo(); // ok
a1.bar(); // error
}
K This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darkay Li |
last post by:
I have try to create an allocator like follow:
// the type of allocator must be some kind of pointer
template <class Type>
class PointerAllocator : public std::allocator<Type>
{
public:
typedef std::allocator<Type> BaseClass;
public:
void destroy(pointer ptr)
|
by: dushkin |
last post by:
Hi,
This is a member function I wrote:
bool MyClass::operator==(const MyClass &a_suaDateTime) const
{
return (m_oleDateTime == a_suaDateTime.DateTime()); //m_oleDateTime
an MFC class
}
I get this error message:
|
by: darkhonor |
last post by:
I'm very new to Windows development, all
of my background is in Linux, so please bear with me. I am working
on a class project and just for fun I'm building a frontend using
VC++ 2003. The project uses the OpenSSL crypto libraries
(specifically the BIGNUM functions). The offending code is:
if (this->rbtnSetKeysize->Checked) {
this->intKeysize = 512;
// Load the Prime Number and calculate the Secret Value
|
by: Bern McCarty |
last post by:
I am using MEC++ in VC 7.1. I had a method on a __gc object that looked
like this:
__property System::UInt32 get_MyProperty(void)
{
System::Byte __pin * pinBytes = &m_byteArray; // entire array is
now pinned
NativeStruct const __nogc* nativeStructP = reinterpret_cast<NativeStruct
const __nogc*>(pinBytes);
|
by: nmrcarl |
last post by:
I'm trying to upgrade a large project from VS 6.0 to VS 2005.
After fixing a lot of things that changed (mostly sloppy coding in the
original project that VS2005 didn't allow), I got the release version to
build successfully. Unfortunately, it crashes right away when I start it.
So now I need to build the debug version. Unfortunately, the compiler gives
innumerable error messages of the sort shown below.
The #include file referenced...
| |
by: Qasimtn |
last post by:
Error occured while compiling the function which is a operator(<) function
if remove the key word const in the argument no error occurs.
Help me i have no idea what i have done wrong with this code.......
i have mentioned the compiler error after the function implementation
#include<iostream>
using namespace std;
//
//Box Class
|
by: mishink7 |
last post by:
i am getting this error
error C2662: 'std::vector<_Ty>::push_back' : cannot convert 'this' pointer from 'const std::vector<_Ty>' to 'std::vector<_Ty> &'
with
and
and
|
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= |
last post by:
Hi all,
I am porting my code in VC++ to VC.net i.e managed. I have seen somewhere
that i need to convert my char* to String*, but String * doesnt perform
pointer arithmetic like String* p; *p++=' ';
So please suggest as to what i have to do? Am i doing wrong by converting
char* to String* in managed VC.net.
Thanks,
Dipesh.
|
by: TheMan1 |
last post by:
Hi, I'm making a simple program in C++.
I have an object named TextReader, with a function GetString(), and I also have another object, TextWriter.
Now when *TextWriter is called, it needs to return a character. It will get this character from TextReader.GetString(). However, I get an error C2662 when I try to implement this.
Here is my dereference operator function for TextWriter:
char TextWriter::operator*() const
{
string tmpStr;...
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |