CNI for C

Andrew Shuttlewood
Wed Apr 7 11:57:00 GMT 2004

On Wed, 2004-04-07 at 12:23, Andrew Haley wrote:
> Geert Bevin writes:
>  > 
>  > is there anything underway to offer something similar to CNI but then
>  > for C and not for C++?
> We haven't been working on this.
> How would you do it?  What is the C equivalent of the this pointer, or
> a virtual function?  I suppose we could write a bunch of macros to do
> the job, but would anyone use them?

I think maybe all anyone really needs is the equivalent of pinvoke, then
they can do it themselves.

Is there a library that allows me to dynamically call a C function
without generating code? Ie, if I know it has an int as the first
argument, and a char * as the second, can I dynamically call it? I think
if there is, then there is no reason that gcj can't be at least as
compatible to C as Mono is alleged to be.

> That's a very interesting idea.  However, the resistance to using CNI
> has been that 
> *  We can't use VM-specific features that may be useful, such as CNI.
>    <>
> So even if we did create C-CNI, wouldn't this still be the case?
> People would still not want to use it, because it's VM specific.

If you had a library that could call C functions then surely you could
just use JNI to attach to it, thus making everybody happy?

Andrew Shuttlewood <>

More information about the Java mailing list