Try manually loading the syntax-case library in test.scm before you use it.  With:

(load "~~/lib/syntax-case")



On Friday, July 29, 2016 8:34 AM, ochi n <ochi12@hotmail.com> wrote:


Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.
This is the code in test.scm

    (define-syntax while
      (syntax-rules ()
        ((while condition body ...)
         (let loop ()
           (if condition
               (begin
                 body ...
                 (loop))
               #f)))))

    (define x 0)
    (while (< x 5)
      (set! x (+ x 1))
      (print x))

When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error:
*** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit"
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
test.o: In function `___setup_mod':
test.c:(.text+0xa): undefined reference to `___G__20_test'
test.o: In function `___init_mod':
test.c:(.text+0x26): undefined reference to `___G__20_test'
test.o: In function `___H__20_test':
test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte'
test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte'
test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte'
test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte'
test.c:(.text+0x214): undefined reference to `___G_x'
test.c:(.text+0x24d): undefined reference to `___G_x'
test.c:(.text+0x3a6): undefined reference to `___G_x'
test.c:(.text+0x450): undefined reference to `___G_x'
test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch'
test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch'
test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error'
test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error'
test.o: In function `____20_test':
test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_'
test.c:(.text+0xd46): undefined reference to `___S_any'
test.c:(.text+0xd62): undefined reference to `___S_body'
test.c:(.text+0xd70): undefined reference to `___S_condition'
test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any'
test.c:(.text+0xd9a): undefined reference to `___S_global'
test.c:(.text+0xdc4): undefined reference to `___S_loop'
test.c:(.text+0xdd2): undefined reference to `___S_ribcage'
test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object'
test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage'
test.c:(.text+0xe34): undefined reference to `___S_x'
collect2: error: ld returned 1 exit status

I tried compiling with the interactive mode using
    (compile-file-to-target "test.scm")
    (quit)
    gambitc -exe test.c
and it compiles well, but when I try to run the exe I get:
    *** ERROR IN | test| -- Operator is not a PROCEDURE
    (#!unbound
     '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))
     '#<procedure #2>
     '*top*)

No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated!
(I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)

_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list