Hi,

On 26 Nov 2018, at 09:28, Yuriy Babah <babah.yuriy06@gmail.com> wrote:

Hi !

I'm trying to call a very simple function from C ++ lib, writed for the test.
function with prototype:

extern "C" float interpolationFunc(float* xm, float* ym, int size, float x).

In Pharo7 wrote:
FFIExamples class >> interpolationFunc_xm: xM ym: yM size: size x: x
    ^ self ffiCall: #(float interpolationFunc #(float * xM , float * yM , int size , float x)) module: 'libinterpolationLib.so'

in Playground i'm doing:
xm :=  FFIExternalArray externalNewType: 'float' size: 2.
ym := xm clone.
#(2 3) doWithIndex: [:each :i | xm at: i put: each].
#(3 4) doWithIndex: [:each :i | ym at: i put: each].
FFIExamples interpolationFunc_xm: xm pointer ym: ym pointer size: 2  x: 2.5 .

This is incorrect. ���xm��� and ���ym��� are already pointers (references)
When you pass "xm pointer��� you are actually passing a pointer to a pointer (a float** in this case) 

This looks better:

FFIExamples 
interpolationFunc_xm: xm getHandle
ym: ym getHandle
size: 2  
x: 2.5 .

Still, you need to do something with those arrays after using them, since you are creating them with externalNewType:��� (which mean it allocates the memory space).
You will need to send #free to them. 
Other solution would be to not use #externalNewType:size: but plain #newType:size:

Cheers, 
Esteban


last expression returnin�� me 0.0, but right is 3.5.

I'm dit the same in Python3 ctypes, and there work's fine.

In UnifiedFFI booklet is absent chapter "Arrays", anybody may help with whot i'm doing wrong?