<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1469716374681_26504">I have no problems running this in the repl.  However, I am getting the same issue when using the -exe flag.  I believe the syntax-case file needs to be linked into the exe, but I haven't had any luck with that either.</div><div id="yui_3_16_0_ym19_1_1469716374681_26505"><br id="yui_3_16_0_ym19_1_1469716374681_26506"></div><div id="yui_3_16_0_ym19_1_1469716374681_26507">I tried linking syntax-case with the source and using gcc to generate the exe per the manual:</div><div id="yui_3_16_0_ym19_1_1469716374681_26508"><br id="yui_3_16_0_ym19_1_1469716374681_26509"></div><div id="yui_3_16_0_ym19_1_1469716374681_26510">bob@ubuntulaptop:~/home/bob/tmp$ gsc -:s -c gambit-syntax-test.scm</div><div id="yui_3_16_0_ym19_1_1469716374681_26511">bob@ubuntulaptop:~/home/bob/tmp$ gsc -o syntax-case.c -c /usr/local/Gambit-C/current/lib/syntax-case.scm</div><div id="yui_3_16_0_ym19_1_1469716374681_26512">bob@ubuntulaptop:~/home/bob/tmp$ gsc -link gambit-syntax-test.c syntax-case.c</div><div id="yui_3_16_0_ym19_1_1469716374681_26513">bob@ubuntulaptop:~/home/bob/tmp$ gsc -obj gambit-syntax-test.c syntax-case.c syntax-case_.c</div><div id="yui_3_16_0_ym19_1_1469716374681_26514">gambit-syntax-test.c:</div><div id="yui_3_16_0_ym19_1_1469716374681_26515">syntax-case.c:</div><div id="yui_3_16_0_ym19_1_1469716374681_26516">syntax-case_.c:</div><div id="yui_3_16_0_ym19_1_1469716374681_26517">bob@ubuntulaptop:~/home/bob/tmp$ gcc gambit-syntax-test.o syntax-case.o syntax-case_.o -lgambc -lm -ldl -lutil</div><div id="yui_3_16_0_ym19_1_1469716374681_26518">bob@ubuntulaptop:~/home/bob/tmp$ ./a.out</div><div id="yui_3_16_0_ym19_1_1469716374681_26519">*** ERROR IN | gambit-syntax-test| -- Operator is not a PROCEDURE</div><div id="yui_3_16_0_ym19_1_1469716374681_26520">(#!unbound2</div><div id="yui_3_16_0_ym19_1_1469716374681_26521"> '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))</div><div id="yui_3_16_0_ym19_1_1469716374681_26522"> '#<procedure #2></div><div id="yui_3_16_0_ym19_1_1469716374681_26523"> '*top*)</div><div id="yui_3_16_0_ym19_1_1469716374681_26524">bob@ubuntulaptop:~/home/bob/tmp$</div><div id="yui_3_16_0_ym19_1_1469716374681_26525"><br id="yui_3_16_0_ym19_1_1469716374681_26526"></div><div id="yui_3_16_0_ym19_1_1469716374681_26527"><br id="yui_3_16_0_ym19_1_1469716374681_26528"></div><div id="yui_3_16_0_ym19_1_1469716374681_26529">;;;; file:  gambit-syntax-test.scm</div><div id="yui_3_16_0_ym19_1_1469716374681_26530">(define-syntax while</div><div id="yui_3_16_0_ym19_1_1469716374681_26531">  (syntax-rules ()</div><div id="yui_3_16_0_ym19_1_1469716374681_26532">    ((while condition body ...)</div><div id="yui_3_16_0_ym19_1_1469716374681_26533">     (let loop ()</div><div id="yui_3_16_0_ym19_1_1469716374681_26534">       (if condition</div><div id="yui_3_16_0_ym19_1_1469716374681_26535">           (begin</div><div id="yui_3_16_0_ym19_1_1469716374681_26536">             body ...</div><div id="yui_3_16_0_ym19_1_1469716374681_26537">             (loop))</div><div id="yui_3_16_0_ym19_1_1469716374681_26538">           #f)))))</div><div id="yui_3_16_0_ym19_1_1469716374681_26539"><br id="yui_3_16_0_ym19_1_1469716374681_26540"></div><div id="yui_3_16_0_ym19_1_1469716374681_26541">(define x 0)</div><div id="yui_3_16_0_ym19_1_1469716374681_26542">(while (< x 5)</div><div id="yui_3_16_0_ym19_1_1469716374681_26543">  (set! x (+ x 1))</div><div id="yui_3_16_0_ym19_1_1469716374681_26452"></div><div id="yui_3_16_0_ym19_1_1469716374681_26544">  (print x))</div><div dir="ltr" id="yui_3_16_0_ym19_1_1469716374681_26545"><br id="yui_3_16_0_ym19_1_1469716374681_26546"></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> On Friday, July 29, 2016 10:57 AM, ochi n <ochi12@hotmail.com> wrote:<br></font></div>  <br><br> <div class="y_msg_container"><div id="yiv1090503675"><style type="text/css">#yiv1090503675 #yiv1090503675 -- P {margin-top:0;margin-bottom:0;}#yiv1090503675 </style><div dir="ltr">
<div id="yiv1090503675divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri, Arial, Helvetica, sans-serif;">
<div>I did try adding each one of these: (load "~~lib/syntax-case") <span>(load "~~/lib/syntax-case")</span> <span>(include "~~lib/syntax-case.scm")</span> at the beginning of the file, but I keep getting:</div>
<div><br clear="none">
</div>
<div><span>*** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression</span></div>
<div><span><br clear="none">
</span></div>
<div><span>Where line 5 is:<br clear="none">
</span></div>
<div><span></span><br clear="none">
</div>
<div><span>(syntax-rules ()</span></div>
<div><span><br clear="none">
</span></div>
<div>I have no idea why this is happening, gambit supports macros and this macros is supposed to be legal. Don't know if it helps, but I'm using the code from this tutorial
<a rel="nofollow" shape="rect" class="yiv1090503675OWAAutoLink" id="yiv1090503675LPlnk656078" target="_blank" href="http://www.willdonnelly.net/blog/scheme-syntax-rules/">
http://www.willdonnelly.net/blog/scheme-syntax-rules/</a></div>
<div>Thanks for your time!<br clear="none">
</div>
<div><br clear="none">
</div>
<div class="yiv1090503675yqt6274136178" id="yiv1090503675yqt26423"><div style="color:rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block;width:98%;">
<div dir="ltr" id="yiv1090503675divRplyFwdMsg"><font style="font-size:11pt;" face="Calibri, sans-serif" color="#000000"><b>From:</b> Bob Coleman <bobcolem@yahoo.com><br clear="none">
<b>Sent:</b> Friday, July 29, 2016 11:22 AM<br clear="none">
<b>To:</b> ochi n; gambit-list@iro.umontreal.ca<br clear="none">
<b>Subject:</b> Re: [gambit-list] Error compiling macros</font>
<div> </div>
</div>
<div>
<div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11245">Try manually loading the syntax-case library in test.scm before you use it.  With:</div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11246"><br clear="none" id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11247">
</div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11216"></div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11248">(load "~~/lib/syntax-case")</div>
<div dir="ltr" id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11249"><br clear="none" id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11250">
</div>
<div class="yiv1090503675qtdSeparateBR"><br clear="none">
<br clear="none">
</div>
<div class="yiv1090503675yahoo_quoted" style="display:block;">
<div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">
<div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">
<div dir="ltr"><font face="Arial" size="2">On Friday, July 29, 2016 8:34 AM, ochi n <ochi12@hotmail.com> wrote:<br clear="none">
</font></div>
<br clear="none">
<br clear="none">
<div class="yiv1090503675y_msg_container">
<div id="yiv1090503675">
<div dir="ltr">
<div id="yiv1090503675divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri, Arial, Helvetica, sans-serif;">
<div>Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.</div>
<div>This is the code in test.scm</div>
<div><br clear="none">
</div>
<div></div>
<div>    (define-syntax while<br clear="none">
<span>    </span>  (syntax-rules ()<br clear="none">
<span>    </span>    ((while condition body ...)<br clear="none">
<span>    </span>     (let loop ()<br clear="none">
<span>    </span>       (if condition<br clear="none">
<span>    </span>           (begin<br clear="none">
<span>    </span>             body ...<br clear="none">
<span>    </span>             (loop))<br clear="none">
<span>    </span>           #f)))))<br clear="none">
<br clear="none">
<span>    </span>(define x 0)<br clear="none">
<span>    </span>(while (< x 5)<br clear="none">
<span>    </span>  (set! x (+ x 1))<br clear="none">
<span>    </span>  (print x))<br clear="none">
<br clear="none">
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:<br clear="none">
<div>*** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit"<br clear="none">
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start':<br clear="none">
(.text+0x20): undefined reference to `main'<br clear="none">
test.o: In function `___setup_mod':<br clear="none">
test.c:(.text+0xa): undefined reference to `___G__20_test'<br clear="none">
test.o: In function `___init_mod':<br clear="none">
test.c:(.text+0x26): undefined reference to `___G__20_test'<br clear="none">
test.o: In function `___H__20_test':<br clear="none">
test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x214): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x24d): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x3a6): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x450): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch'<br clear="none">
test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch'<br clear="none">
test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error'<br clear="none">
test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error'<br clear="none">
test.o: In function `____20_test':<br clear="none">
test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_'<br clear="none">
test.c:(.text+0xd46): undefined reference to `___S_any'<br clear="none">
test.c:(.text+0xd62): undefined reference to `___S_body'<br clear="none">
test.c:(.text+0xd70): undefined reference to `___S_condition'<br clear="none">
test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any'<br clear="none">
test.c:(.text+0xd9a): undefined reference to `___S_global'<br clear="none">
test.c:(.text+0xdc4): undefined reference to `___S_loop'<br clear="none">
test.c:(.text+0xdd2): undefined reference to `___S_ribcage'<br clear="none">
test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object'<br clear="none">
test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage'<br clear="none">
test.c:(.text+0xe34): undefined reference to `___S_x'<br clear="none">
collect2: error: ld returned 1 exit status</div>
<br clear="none">
I tried compiling with the interactive mode using <br clear="none">
    (compile-file-to-target "test.scm")<br clear="none">
    (quit)<br clear="none">
    gambitc -exe test.c<br clear="none">
and it compiles well, but when I try to run the exe I get:<br clear="none">
<div>    *** ERROR IN | test| -- Operator is not a PROCEDURE<br clear="none">
<span>    </span>(#!unbound<br clear="none">
<span>    </span> '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))<br clear="none">
<span>    </span> '#<procedure #2><br clear="none">
<span>    </span> '*top*)<br clear="none">
<br clear="none">
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated!<br clear="none">
</div>
<span>(I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well</span>)<br clear="none">
</div>
<div></div>
</div>
</div>
</div>
<br clear="none">
_______________________________________________<br clear="none">
Gambit-list mailing list<br clear="none">
<a rel="nofollow" shape="rect" ymailto="mailto:Gambit-list@iro.umontreal.ca" target="_blank" href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br clear="none">
<br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div></div>
</div>
</div></div><br><div class="yqt6274136178" id="yqt40920">_______________________________________________<br clear="none">Gambit-list mailing list<br clear="none"><a shape="rect" ymailto="mailto:Gambit-list@iro.umontreal.ca" href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br clear="none"><a shape="rect" href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br clear="none"></div><br><br></div>  </div> </div>  </div></div></body></html>