[gambit-list] calling interpreted scheme code from compiled C

James Long longster at gmail.com
Tue Jan 20 01:32:13 EST 2009


The warning is just a warning.  It's a common message from Gambit when  
dynamically loading libraries.  The issue is that when a library is  
loaded, it references a few functions which don't exist yet.  Most  
likely these requirements will fulfilled by loading other libraries  
which define those functions.  For example:

;;test.scm
(c-define (foo) () void "foo" ""
     (bar))

;;test2.scm
(define (bar)
     (display "hello"))

% gsc test.scm
% gsi
Gambit v4.3.2

 > (load "test")
*** WARNING -- Variable "bar" used in module "test.o1" is undefined
"~/test.o1"
 > (load "test2")
"~/test2.scm"
 > (foo)
hello>

So it's probably just a timing issue.  You could add `(load "test")'  
at the top of wrapper.scm and compile wrapper.scm, and then run `gsi  
wrapper.o1' instead.

On Jan 19, 2009, at 8:48 PM, TongKe Xue wrote:

> Sorry, that last line should say:
>
> gsi test.scm
> *** WARNING -- Variable "disp" used in module "wrapper-s" is undefined
>
>
>
> On Mon, Jan 19, 2009 at 5:43 PM, symbolic expression <symbolic.expression at gmail.com 
> > wrote:
> hi!
>
>   I have wrapper.scm (which is compiled code), and test.scm (which  
> is interpreted)
>
>   i.e. (compile-file-to-c "wrapper"); (link-flat '("wrapper ...)  
> output: "blah.o1.c"); gcc -shared -fPIC ... blah.o1.c -o blah.o1
>
>   test.scm:
>   (load "blah")
>   ...
>
>   and I run everything with "gsi test.scm"
>
>   Now, here's the problem. In test.scm, I need to call a  
> glutDisplayFunc, which requires a _C_ callback. Okay, so I define  
> function with (c-define (c-disp ...) ... (disp)). (disp) is the  
> scheme funfction that does the real workd; c-disp is a c wrapper  
> around disp. Since test.scm is interpted, I have to put it in  
> wrapper.scm -- however, I want to keep disp in test.scm (rapid  
> prototypinhg, changing it on the fly, etc ...). Question is, how can  
> I get c-disp (which is in wrapper.scm) to get call (disp), which is  
> in test.scm?
>
>   if I just do wrapper.scm:
>
> (c-define (c-disp) () void "f" "" (disp))
>
>   and test.scm:
> (load "graphics")
>
> ;(c-define (c-disp) () void "f" "" (disp))
>
> (define (disp)
>   (glClear GL_COLOR_BUFFER_BIT)
>   (glutWireTeapot 0.5))
>
> and run gsi test.scm, I get:
>
> $gsi test.scm
> *** WARNING -- Variable "format" used in module "wrapper-s" is  
> undefined
>
> so the question is ... how can i get compile scheme code to 'wait'  
> in order to call interpted scheme code?
>
> thanks!
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20090120/3ad55c77/attachment.htm>


More information about the Gambit-list mailing list