I've got a problem: I must use an int java array in a C code. Using JNI
i wrote this code:
jsize len = (*env)->GetArrayLength (env, payload); //payload is the
name of java array
jint *body = (*env)->GetIntArrayEle ments(env, payload, 0);
int cpayload [len]; // C array
int i;
for (i=0; i<len; i++)
{
cpayload[i] = body[i]; // copying the java array value into C array
value
}
input.d_ip=0;
input.data_size =len;
input.data=(u_c har)*body; //here there is the error
the compiler says this:
warning: assignment makes pointer from integer without a cast
P.S. data is define in this way:
u_char *data; 2 3660
andrea_ wrote: I've got a problem: I must use an int java array in a C code. Using JNI i wrote this code:
jsize len = (*env)->GetArrayLength (env, payload); //payload is the name of java array jint *body = (*env)->GetIntArrayEle ments(env, payload, 0); int cpayload [len]; // C array int i; for (i=0; i<len; i++) { cpayload[i] = body[i]; // copying the java array value into C array value }
input.d_ip=0; input.data_size =len; input.data=(u_c har)*body; //here there is the error
the compiler says this: warning: assignment makes pointer from integer without a cast
P.S. data is define in this way: u_char *data;
The cast is wrong; write:
input.data=(u_c har *)body;
Zara wrote: andrea_ wrote:
I've got a problem: I must use an int java array in a C code. Using JNI i wrote this code:
jsize len = (*env)->GetArrayLength (env, payload); //payload is the name of java array jint *body = (*env)->GetIntArrayEle ments(env, payload, 0);
<snip>
input.data=(u_c har)*body; //here there is the error
the compiler says this: warning: assignment makes pointer from integer without a cast
P.S. data is define in this way: u_char *data;
The cast is wrong; write:
input.data=(u_c har *)body;
That will get rid of the warning and, assuming u_char is a typedef for
unsigned char is completely valid as far as C is concerned. However I
would suggest the OP ask somewhere where the JNI is on topic to see if
this is the right was to access a Java int array. Since the J in JNI
stands for Java I would suggest a group with java in the name, possible
comp.lang.java. programmer, but check *their* FAQ, charter and a load of
posts to see what goes on there before posting.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brad Moore |
last post by:
Hey all,
I'm getting the following compiler error from my code. I was wondering
if anyone could help me understand the concept behind it (I actually did
try and compile this degenerate example).
int foo(const char* argv) { return 0; }
int main(int argc, char* argv)
{
|
by: Trep |
last post by:
Hi there!
I've been having a lot of difficult trying to figure out a way to convert
a terminated char array to a system::string for use in Visual C++ .NET
2003.
This is necessary because I have some legcay C code that needs to process
a string taken from a textbox, then I need to re-display the string as the
textbox->Text. I easily found how to convert from system::string to char
but I can't figure out how to go the other way!!
|
by: jeff |
last post by:
how do you convert form byte to Int32 while retaining the binary
value of the byte array
|
by: Bryan Parkoff |
last post by:
I have two variables: "char A" and "short B". I can be able to convert
from A to B using explicit case conversion with no problem like "B = short
(A);". Right now, I have two variables: "char T" and "short A". T has
an array of six elements. I desire to capture first element and second
element as two bytes into word as short.
The problem is that "A" captures only one element instead of two
elements. I have looked at machine language...
|
by: Kueishiong Tu |
last post by:
How do I convert a Byte array (unsigned char managed) to a
char array(unmanaged) with wide character taken into
account?
| |
by: GRoll35 |
last post by:
I get 4 of those errors. in the same spot. I'll show my parent class,
child class, and my driver.
All that is suppose to happen is the user enters data and it uses
parent/child class to display it.
here is the 4 errors.
c:\C++\Ch15\Employee.h(29): error C2440: '=' : cannot convert from
'char ' to 'char '
|
by: Koolrans |
last post by:
Hi All,
Don't know if this is covered somewhere else. Could not find it. I
have a problem for which I need a solution.
I have an array of char chr. I want to convert this to an array
of uint32 it. What I require is that for the first integer, the
value would be of the four chars. This means, the first 8 bits will be
tmp, the second 8 bits would be tmp and so on.
|
by: Frank Liebelt |
last post by:
Hi
I try to convert a int array into a char array. My code: void exec()
{
char mds;
int i;
int mdc =
{50,100,97,51,101,50,99,51,48,55,100,102,55,53,101,56,100,48,101,53,101,52,99,98,102,55,101,50,53,100,49,53};
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
System.Text.UTF8Encoding str = new System.Text.UTF8Encoding();
string s = new string((char)107, 1);
s += new string((char)62, 1);
|
by: rtillmore |
last post by:
Hello,
I did a quick google search and nothing that was returned is quite
what I am looking for. I have a 200 character hexadecimal string that
I need to convert into a 100 character string.
This is what I have so far:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
|
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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |