About save-lisp-and-die in Windows ?

Discussion of Common Lisp
Post Reply
anta40
Posts: 19
Joined: Fri Oct 10, 2008 10:27 pm
Contact:

About save-lisp-and-die in Windows ?

Post by anta40 » Wed Oct 15, 2008 9:33 pm

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!" ?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

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

Post by ramarren » Wed Oct 15, 2008 9:57 pm

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.

dmitry_vk
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan
Contact:

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

Post by dmitry_vk » Wed Oct 15, 2008 11:39 pm

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)

Post Reply