Re: GCJ: Is it possible to call C++ from Java using GCJ CNI?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 28 Apr 2008 15:29:06 +0100
Andrew Haley <aph@xxxxxxxxxx> wrote:

> Gareth Buxton wrote:
> 
> > I have been trying to find out how to call C++ code from Java using
> > CNI. Is this at all possible?
> > 
> > I found this page in the documentation which suggests a possible
> > way:
> > 
> > http://gcc.gnu.org/onlinedocs/gcj/Interfaces.html#Interfaces
> > 
> > But I have been unable to make anything  work using this. Are there
> > any code examples?
> 
> All of libgcj.  Here's a simple example:
> 
> java/lang/VMFloat.java:
> 
> package java.lang;
> 
> 
> final class VMFloat
> {
>   ...  
> 
>   static native int floatToIntBits(float value);
> 
> 
> 
> natVMFloat.cc:
> 
> jint 
> java::lang::VMFloat::floatToRawIntBits(jfloat value)
> {
>   union u u;
>   u.d = value;  
>   return u.l;
> }
> 
> Andrew.

Thanks. That solved it :)

Gareth

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux