Re: Binding to C - Arrays and Access Violation

2016-02-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 04:19:37 UTC, jmh530 wrote: A few extra questions: 1) In other parts of the code I'm using extern(System), but that doesn't work for these. Why is extern(C) used for function pointers?, extern(C) is only used with function pointers when it's needed. It

Binding to C - Arrays and Access Violation

2016-02-02 Thread jmh530 via Digitalmars-d-learn
I'm working on generating a binding to a C library. I've got the .h file converted and can call some parts of the library with no errors. However, I have reached a stumbling block in a critical part. The library requires passing function pointers to various functions in the library. When I

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread biozic via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 22:56:28 UTC, jmh530 wrote: I'm working on generating a binding to a C library. I've got the .h file converted and can call some parts of the library with no errors. However, I have reached a stumbling block in a critical part. The library requires passing

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 February 2016 at 22:56:28 UTC, jmh530 wrote: My D code calls a C function. One of the parameters to the C function is a function pointer to a D function. This D function (below) is one that I copied from the C library's tutorial. I only slightly changed the signature. This

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 00:28:24 UTC, biozic wrote: Is grad allocated in the D code? If so, it could have been collected because the GC lost track of its use when passing to and from the C code. Or is grad owned by the C code? If so, either there is a bug in the library or it's

Re: Binding to C - Arrays and Access Violation

2016-02-02 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 00:37:25 UTC, Mike Parker wrote: The parameter to the C function should be declared as extern(C), and so should your function implementation. extern(C) alias FuncPtr = double function(uint, const(double)*, double*, void*); extern(C) void