Passing R/W arrays to external libraries

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Passing R/W arrays to external libraries

Post 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;
}
User avatar
Kjell
Posts: 1915
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,

Sure, simply use xptr as argument type ;)

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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.
Post Reply