Re: Communication between D and C with dynamic arrays

2014-08-10 Thread ketmar via Digitalmars-d-learn
On Sun, 10 Aug 2014 19:39:29 + seany via Digitalmars-d-learn wrote: > Solved : > http://stackoverflow.com/questions/25232194/c-and-d-communication/25232265#25232265 almost exactly what i wrote in my first reply. except that i wrote about using .ptr and size_t for item counter too. signatur

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
Solved : http://stackoverflow.com/questions/25232194/c-and-d-communication/25232265#25232265

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
of course I read this : http://dlang.org/interfaceToC.html I have 64 bit OS

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
So here is the final situtaion I have a file: software_pluginInterface.di Here I declare : extern (C): void performComputation(char lib[], char func[], void* ptr[], int varNum ); // lib and func will be used later Then i have the corresponding C file: software_pluginInterface.c, where I dec

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread anonymous via Digitalmars-d-learn
On Sunday, 10 August 2014 at 15:37:41 UTC, seany wrote: On Sunday, 10 August 2014 at 15:34:30 UTC, ketmar via Digitalmars-d-learn wrote: from D side -- yes. just don't store passed pointer on C side, 'cause it can be changed on array resize. Excellent, So if I have int [] array; void * pt

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread via Digitalmars-d-learn
On Sunday, 10 August 2014 at 14:26:29 UTC, seany wrote: In D, arrays are dynamic. However, to the best of my knowledge, in C, they are static. I am having difficulty in imagining how to send D arrays to a C function. My first Idea was to make a pointer to the array. then find the size of th

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
On Sunday, 10 August 2014 at 15:34:30 UTC, ketmar via Digitalmars-d-learn wrote: from D side -- yes. just don't store passed pointer on C side, 'cause it can be changed on array resize. Excellent, So if I have int [] array; void * ptr_to_array = &array; /* populate array here */ C_Functi

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread ketmar via Digitalmars-d-learn
On Sun, 10 Aug 2014 15:24:29 + seany via Digitalmars-d-learn wrote: > Thank you, so the running out of space problem is taken care of > automatically? from D side -- yes. just don't store passed pointer on C side, 'cause it can be changed on array resize. but if you want to be able to resiz

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
Thank you, so the running out of space problem is taken care of automatically?

Re: Communication between D and C with dynamic arrays

2014-08-10 Thread ketmar via Digitalmars-d-learn
On Sun, 10 Aug 2014 14:26:27 + seany via Digitalmars-d-learn wrote: > I am having difficulty in imagining how to send D arrays to a C > function. do something like this: === C SIDE === void c_array_processing (int *items, size_t item_count) { // use items pointer as normal C-like array po

Communication between D and C with dynamic arrays

2014-08-10 Thread seany via Digitalmars-d-learn
In D, arrays are dynamic. However, to the best of my knowledge, in C, they are static. I am having difficulty in imagining how to send D arrays to a C function. My first Idea was to make a pointer to the array. then find the size of the array, which itself is an array, therefore take the po