On Wed, Apr 07, 2021 at 07:46:20AM +0200, Alexander Burger wrote: > OK, so now we have a pointer to a structure filled by evalInR(). > ... > (struct (evalInR "6*4") ...)
In fact this depends on what exactly evalInR() returns. If it returns a pointer to a dynamically allocated structure, and the caller is responsible to de-allocate it, you would do (let P (evalInR "6*4") (prog1 (struct P ...) (free P) ) ) If, however, the structure is statically allocated, you can also give the structure's structure directly as the return value specification: (native `*RinC "evalInR" '(...) "Cmd") For example, as a (somewhat conceived) test case static struct { char *s; int i[4]; double d; char nm[8]; } Data; void *foo(void) { Data.s = "Hello"; Data.i[0] = 1; Data.i[1] = 2; Data.i[2] = -3; Data.i[3] = 4; Data.d = 0.99; strcpy(Data.nm, "world"); return &Data; } Then in the REPL : (native "./test.so" "foo" '(S I (I . 2) (B . 4) 100 (C . 8))) -> ("Hello" 1 (2 -3) (4 0 0 0) 99 ("w" "o" "r" "l" "d")) ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe