binding to C++

2017-05-26 Thread drug via Digitalmars-d-learn
Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump message so I don't know where is the difference. For

Binding to C

2015-05-11 Thread TJB via Digitalmars-d-learn
I'm sure this question has been asked a thousand times. I've even asked similar questions in the past (I've been away for quite a while). But all of the tutorials that I have found assume quite a lot and leave a lot to be inferred. Is there a simple step by step tutorial demonstrating how to ca

Re: binding to C++

2017-05-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump

Re: binding to C++

2017-05-26 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump

Re: binding to C++

2017-05-29 Thread drug via Digitalmars-d-learn
27.05.2017 02:44, Nicholas Wilson пишет: Thats weird. DMD may have got the mangling wrong. Could you post the exact mangling (i.e. non-demangled)? And if DMD has got it wrong and its just the one function you could just `pragma(mangle, ...);` it. I use pragma(mangle, "...") (how I forget about i

Re: binding to C++

2017-05-30 Thread Oleksii via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump

Re: Binding to C

2015-05-12 Thread Vadim Lopatin via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 03:20:34 UTC, TJB wrote: I'm sure this question has been asked a thousand times. I've even asked similar questions in the past (I've been away for quite a while). But all of the tutorials that I have found assume quite a lot and leave a lot to be inferred. Is there a

Re: Binding to C

2015-05-12 Thread Cassio Butrico via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 03:20:34 UTC, TJB wrote: I'm sure this question has been asked a thousand times. I've even asked similar questions in the past (I've been away for quite a while). But all of the tutorials that I have found assume quite a lot and leave a lot to be inferred. Is there a

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 tr

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 funct

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 fun

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 misus

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 takeFuncPtr(FuncPtr)

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 depe