On Tue, Jul 14, 2009 at 11:36 PM, R.  Kars  Brouwer<[email protected]> wrote:
> I would like to make calls to C code from J. Please  provide me with a link
> to information regarding this

There are two ways to do this.

The dynamic call interface is documented in the User under "DLLs and
Memory Management" (and you may need to read the example scripts too).
 This uses the 15!:0 foreign function to call C functions with simple
types directly, the names of functions resolved with the dynamic
loader.

The other way works if you embed the J shared library to a program,
and start the J interpreter from there (which is what the jconsole
executable does, but you need a custom executable).  In this case, you
can call the JSM function to set five callbacks the J interpreter
uses, one of which is the "window driver" callback which handles 11!:n
foreign calls.  This is much more sparsely documented, also in the
"DLLs and Memory Management" section of the User's guide and examples.

The difference between the two methods is that the first allows you to
call various C functions often not specifically made for J, because
you create the arguments of the function and possibly build data
structures in memory from J.  (You still often need some C wrappers.)
In contrast, in the second method you pass a J vector noun to the
function and the C function is supposed to handle reading data from
that noun and do any bridging.

Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to