Alex,

I haven't done very much of that myself, but have you looked at chapter 21 of 
JforC? 
https://www.jsoftware.com/help/jforc/calling_external_programs.htm#_Toc191734429

Cheers, bob

> On Oct 5, 2021, at 09:21, Alex Shroyer <[email protected]> wrote:
> 
> How do I send/receive data structures to/from C functions using the cd verb?
> 
> For example if I have this C library saved as /tmp/example.dylib, how do I
> call it from J?
> 
> // C code:
> struct stuff {double a[2]; int i;};
> void fn(struct stuff *x) {x->a[x->i] += 100;}
> 
> NB. J code:
> data =: (2.3 4.5);0    NB. the data I would like to send to fn (array of 2
> doubles; int)
> '/tmp/example.dylib fn (declaration)' cd (parameters)
> 
> Specifically, what do I use for the (declaration) and what do I use for
> (parameters)?
> I presume I should use something from
> https://www.jsoftware.com/help/dictionary/dx003.htm but I'm unsure how to
> then specify it in the (declaration).
> 
> Is there a relevant example somewhere?
> 
> Thanks,
> Alex
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to