Page 1 of 1

Passing R/W arrays to external libraries

Posted: Thu Dec 19, 2013 12:28 pm
by Rado1
Is it possible to pass an array as parameter to external library and change values of array by the library? All my trials ended up with access violation errors.

ZExternalLibrary:

Code: Select all

void foo(int[] arr) {}
Call from ZExpression:

Code: Select all

int[10] arr;
foo(arr);
Here is the corresponding C++ code:

Code: Select all

export void foo(int* arr) {
	int i = 0;
	for(int i = 0; i < 10; ++i)
		arr[i] = i;
}

Posted: Thu Dec 19, 2013 12:34 pm
by Kjell
Hi Rado1,

Sure, simply use xptr as argument type ;)

K

Posted: Thu Dec 19, 2013 1:37 pm
by Rado1
Thanks Kjell! Stupid me. At the moment I'm using C++, Java, expression language for a technology we are developing in company, ZGE expressions... so sometimes I cannot remember proper constructs. Thanks again.

Rado1.