Page 1 of 1

About save-lisp-and-die in Windows ?

PostPosted: Wed Oct 15, 2008 9:33 pm
by anta40
I'm learning to make a Win32 executable using SBCL's save-lisp-and die from this article .

On that articles, the author enters the code directly while running SBCL, and I'm wondering how to do that from file.

My first attempt is this code : test.lisp
Code: Select all
(defun hello()
  (format t "Hello, (cruel) world!~%"))


The exe is created by :sb-ext:save-lisp-and-die "test.exe" :executable t :toplevel 'hello. But when I run it, the output is pretty strange :
This is experimental prerelease support for the Windows platform: use
at your own risk. "Your Kitten of Death awaits!"
Hello, (cruel) world!

debugger invoked on a TYPE-ERROR: The value NIL is not of type (SIGNED-BYTE 32).


Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

(no restarts: If you didn't do this on purpose, please report it as a bug.)

(SB-UNIX:UNIX-EXIT NIL)[:EXTERNAL]
0]


compared to the output from the article :
This is experimental prerelease support for the Windows platform: use
at your own risk. "Your Kitten of Death awaits!"
Hello world!


Where is my mistake ? And BTW, how can I suppress the "This is experimental prerelease ..." message, so the output would be just "Hello world!" ?

Re: About save-lisp-and-die in Windows ?

PostPosted: Wed Oct 15, 2008 9:57 pm
by ramarren
As reading the documentation would reveal, the toplevel function is not supposed to return, but your does, and the system is getting confused. I am not sure why it is so, but your code should be:
Code: Select all
(defun hello()
  (format t "Hello, (cruel) world!~%"))
  (sb-ext:quit))


And as for the kitten of death message, I think the only option is to compile from the modified sources, but maybe there is some kind of option? I do not use SBCL on windows, so I am not sure, but from looking at the source it is not conditionalized.

Re: About save-lisp-and-die in Windows ?

PostPosted: Wed Oct 15, 2008 11:39 pm
by dmitry_vk
anta40 wrote:debugger invoked on a TYPE-ERROR: The value NIL is not of type (SIGNED-BYTE 32).

I don't known how the top-level function is handled, but it might be that this function should return the process exit code (which is an integer). So sbcl is trying to coerce it to an integer and return.
Try the following:
Code: Select all
(defun hello()
  (format t "Hello, (cruel) world!~%"))
  0)