[Ecls-list] Detection and handling of compiler conditions

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Thu Aug 21 09:52:31 UTC 2008


I have simplified the whole mechanism, so that WITH-COMPILATION-UNIT
is no longer needed.

	(use-package :c)
	(let ((warnings nil))
	  (handler-bind ((compiler-error #'(lambda (c)
					     (push c warnings)
					     (abort c)))
			 (compiler-message #'(lambda (c)
					       (push c warnings)
					       (muffle-warning))))
	    (let ((*compile-verbose* nil))
	      (compile-file "foo.lsp" :system-p t)))
	  (format t "~&;;; Printing compiler messages")
	  (loop for m in (nreverse warnings)
	     for i from 0
	     do (format t "~&~@<;;; ~@;Message #~D~%~A~:>" i m)))

Using foo.lsp as

(defun foo (x)
 (print x t extra-argument))

(let x (print 2))

Gives

;;; Printing compiler messages
;;; Message #0
;;; Variable EXTRA-ARGUMENT was undefined. Compiler assumes it is a global.
;;; Message #1
;;; Internal error: in file foo.lsp, position 1, and form
;;;   (LET X
;;;     (PRINT 2))
;;; X is not of type LIST.

-- 
Instituto de Física Fundamental
CSIC, Serrano, 113, Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com


More information about the ecl-devel mailing list