Hi Alex, the wrappers with primitive arguments do work now when defined like this with transient symbols:
(de pgamma ("X" "Y" "Z" "I" "J") (native `*LibRmath "pgamma" 1.0 (cons "X" 1.0) (cons "Y" 1.0) (cons "Z" 1.0) "I" "J" ) ) ## double› pgamma(double, double, double, int, int); With your tips I could define wrappers for functions with pointer args too (de pnorm_both ("X" "I" "J") (use "Y" "Z" (native `*LibRmath "pnorm_both" NIL (cons "X" 1.0) '("Y" (8 . 1.0)) '("Z" (8 . 1.0)) "I" "J" ) (list "Y" "Z") ) ) ## void› pnorm_both(double, double *, double *, int, int);/* both tails */ does work (scl 3): : (rmath~pnorm_both 1.2 2 3) -> (-122 -2162) now I only have to understand the meaning of some of these functions. What I find irritating is that the pointer args are not used for input but only as a kind of return values. Thanks for your help! Cheers Thorsten Am So., 15. Nov. 2020 um 22:55 Uhr schrieb Alexander Burger < a...@software-lab.de>: > Hi Thorsten, > > hmm, this is not correct: > > > (de pnorm_both ("X" "Y" "Z" "I" "J") > > (! native `*LibRmath "pnorm_both" 1.0 (cons "X" 1.0) '("Y" (1.0 . 4)) > > '("Z" (1.0 . 4)) "I" "J" ) ) > > "Z" is an argument to the function, so it is bound to some evaluated value. > > But this value is ignored, because in > > '("Z" (1.0 . 4)) > > "Z" is a *return* value. Also, (1.0 . 4) makes no sense here. A structure > argument is > > '(Var (<size> . <returnSpec)) > > but 1.0 is no size (it is too big, something like 1000000) and 4 is no > return > spec. > > > If you want to pass a buffer to receivea double (the double* in the C > signature), you would do: > > (use MyDouble > (native `*LibRmath "pnorm_both" 1.0 ... > '(MyDouble (8 . 1.0)) ... ) > ... do something with MyDouble ...) > > (8 . 1.0) allocates 8 bytes on the stack, passes the pointer to the C > function, > receives a double in this place, and stores it in the symbol MyDouble. > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >