Go to Post Is your team sponsored by Rube Goldberg? - bdaroz [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 27-12-2010, 15:15
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Native C string (char*) to java String

I'm trying to get the Java ZomB bindings working, and I seem to be having an issue with getting returned C strings (a const char* to be exact). I have this function:
Code:
private static final Function getstringfnc = NativeLibrary.getDefaultInstance().getFunction("ZomBDashboardGetString");
public String GetString(String name)
{
    int returnstring = getstringfnc.call1(Pointer.createStringBuffer(name));
    return Pointer.NativeUnsafeGetString(Address.fromPrimitive(returnstring));
}
and this C declaration:
Code:
extern "C"
{
    const char* ZomBDashboardGetString(const char* name);
}
and every time I call GetString("value"), my program dies (but it stills says code on the DS). I can, however, pass strings to functions fine.
Java Source attached, C header and out file are on FIRST Forge (just use the latest build's installer, and its in C:\Program Files\ZomB\Bindings)
Attached Files
File Type: zip src.zip (4.3 KB, 20 views)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unflatten from String Patrick Chiang Programming 2 20-02-2010 09:31
string Adama Inventor 1 07-11-2007 14:45
String Theory Michael Hill Math and Science 20 02-09-2005 14:11
is string legal? Jeremy L Kit & Additional Hardware 7 07-03-2004 16:28


All times are GMT -5. The time now is 08:51.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi