I have the following chicken scheme code:
; test.scm
(use coops)
(define-class <Vector2> ()
(
(x initform: 0 reader: get-x writer: set-x! )
(y initform: 0 reader: get-y writer: set-y! )
)
)
(define v (make <Vector2>))
(print v)
(newline)
Running
$ csc test.scm
$ ./test
gives
#<coops instance of `<Vector2>'>
which is what I expect.
when I add
(declare (uses coops))
above
(use coop)
Running
$ csc test.scm
Gives
test.o: In function `f_494':
test.c:(.text+0x908): undefined reference to `C_coops_toplevel'
collect2: error: ld returned 1 exit status
Error: shell command terminated with non-zero exit status 256: 'gcc' 'test.o' -o 'test' -L/usr/local/lib -Wl,-R'/usr/local/lib' -lchicken -lm -ldl
What gives? Thanks in advance.
These declarations are really intended for static linking.
The idea here is that the compiler will generate a call to the toplevel of coops, so that this unit is initialised, but it's not linked into your program (use
will load and link the extension at runtime into your program).
I know, it's confusing. At least in CHICKEN 5 this stuff has been made a bit simpler. A release candidate for CHICKEN 5 will be made in two weeks if we don't hit any major snags, so it really is quite close to a release!