D array to c

Harpo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 5 20:40:40 PDT 2014


Hello I need to pass a array in D to c. I have edited the code to 
the important parts. Normally in C I would just do this:

void myFunction(int *array)
{
}

Then pass it a array of whatever size. However I actually need 
the array to be in a struct so...

typedef struct{int* array;} examplestruct;

void myFunction(examplestruct parameter){


}

On the D end what type structure do I need to use to pass a array 
of unknown size inside a struct to the c function? I have tried 
stuff like:

struct examplestruct {long* array;}
long numar[50];
examplestruct parameters;
parameters.array = numuar;

When I do that I get type conflictions.  Error: cannot implicitly 
convert expression (numar) of type long[50] to long*...
I am not sure what setup I need to have here. Anyone know whats 
up?

Thanks! -Harpo


More information about the Digitalmars-d-learn mailing list