[plt-scheme] FFI problem

From: K.S.Sreeram (sreeram at tachyontech.net)
Date: Mon Jul 30 17:30:13 EDT 2007

Hi,

How do I store a function pointer in a struct? I tried the following
code, but it doesn't work.

(require (lib "foreign.ss"))
(unsafe!)

(define _TESTFUNC (_fun _int -> _int))

(define-cstruct _TEST
  ((a _int)
   (f _TESTFUNC)))

(define (plus1 x) (+ x 1))

(make-TEST 0 plus1)

I get the following error :
"ptr-set!: setting fpointer value with extra arguments"

Thanks
[sreeram;]


Posted on the users mailing list.