I think you need to define the import library when building both test.scm
and test.import.scm. If I do so, your test works:

dleslie@marvin:~$ csc -s test.scm -j test
dleslie@marvin:~$ csc -s test.import.scm -j test
dleslie@marvin:~$ csi

CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0 (rev 3f195ba)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2014-06-02 on yves (Linux)

#;1> (import test)
; loading ./test.import.so ...
; loading /var/lib//chicken/7/chicken.import.so ...
#;2> (a-macro 1 2)
3
#;3>

-Dan

On Wed, Sep 10, 2014 at 3:26 AM, Richard <plui...@freeshell.de> wrote:

> On Wed, 10 Sep 2014 00:01:54 -0700
> alex <a...@cs.utah.edu> wrote:
>
> > Hi,
> >
> > I defined a macro. I compiled it separately and built it into my main
> > program. When my main program calls the load procedure on normal
> > Scheme source files, the procedures in these files use the macro
> > without complaint.
> >
> > However, when it loads the dynamic object code created from compiling
> > those same source files, I get an error about an "unbound value" in a
> > subexpression of a macro expression. This seems to be because the
> > macro expressions are being evaluated as normal procedure
> > applications. If I insert the macro definition verbatim into each
> > source file before I compile it, the errors do not occur.
> >
> > I tried passing both the source file and the macro definition file as
> > input to the compiler. The errors remain.
> > What else can I do to ensure that the dynamic object code knows about
> > the macro definition?
> >
> > --Alex
> >
> > _______________________________________________
> > Chicken-users mailing list
> > Chicken-users@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/chicken-users
>
> Try wrapping a module around the code to be compiled separately.
> Compile it using the '-j <module-name>' flag then compile the generated
> scheme file: <module-name>.import.scm
>
> $ cat test.scm
>
> (module test
> *
> (import chicken scheme)
>
> (define-syntax a-macro
>   (syntax-rules ()
>     ((_ l r) (+ l r))))
>
> (define (a-function l r)
>   (+ l r))
>
> )
>
> compile like so:
> $ csc -s test.scm -j test
> $ csc -s test.import.scm
>
> use it like so:
> $ csi
> #;1> (load "test.so")
> #;2> (import test)
> #;3> (a-function 1 2)
> 3
> #;4> (a-macro 1 2)
> 3
>
> I hope this is useful to you,
> greetings,
> Richard
>
>
>
> _______________________________________________
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to