On Thu, Jul 05, 2007 at 09:35:26AM +0200, felix winkelmann wrote: > On 7/4/07, Robin Lee Powell <[EMAIL PROTECTED]> wrote: > >As a related question, something I ran across in libxmmsclient > >that seems particularily tricky: a function with an int return > >value, but an int32_t *foo argument where the *actual* data is > >returned. > > > >In whichever method(s) you reccomend, how would I set up the > >32-bit integer pointer, and then read data out of it after the > >call? > > ; manually: > > (define foo (foreign-lambda int "foo" (c-pointer int))) > > (let-location ((n int 0)) (my-function n) n) > > or: > > ; easyffi: > > #>? > int foo(___in int *x); > <# > > (foo 123)
I can't really follow the first version, but the second version seems the opposite of what I was looking for; I don't care what I pass in, I care about reading what gets written to *x. I first tried: #>? int foo(int *x); <# (define-external val unsigned-int32) (foo val) But easyffi complained that the type wasn't u32vector, so I ended up with: (define intval (s32vector 999999)) (foo val) which seems to work. I have a similar function: #>? int bar(char *x); <# Which I'm handling like so: (define-external vstring c-string "N/A") (bar (location vstring)) Could I drop the (location ...) call by using ___out? I guess it would just be: (define vstring (bar)) , huh? Oh, but http://chicken.wiki.br/easyffi says you can't do that with strings; nevermind. -Robin, still struggling with FFI, obviously. -- http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/ Reason #237 To Learn Lojban: "Homonyms: Their Grate!" Proud Supporter of the Singularity Institute - http://singinst.org/ _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
