-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
symbol conflicts when loading a file #4
Comments
Loading in a completely empty package does work ... although I now get |
Is there some way to use files from I'd need some more include files, and I'd like to avoid writing that by hand. |
Hi! Not sure if you still need or want a solution but perhaps it will be helpful to others. I ran into the same problem but was able to solve it by wrapping the call to use-package with a handler-bind form that invokes the take-new restart. Below is the code for the function with my additions: (defun include-libc-file (include-file)
(let ((libc-package (find-package (format nil "VACIETIS.LIBC.~:@(~A~)"
include-file))))
(unless libc-package
(error "Can't find libc include file ~a" include-file))
(handler-bind ((sb-ext:name-conflict
(lambda (c)
(invoke-restart 'sb-impl::take-new))))
(use-package libc-package))
(awhen (and (boundp (pp-defines libc-package))
(symbol-value (pp-defines libc-package)))
(maphash (lambda (name expansion)
(setf (gethash (intern (symbol-name name) *package*)
(compiler-state-pp *compiler-state*))
expansion))
it))
(awhen (probe-file
(merge-pathnames
(format nil "../libc/~a" include-file)
#.(or *compile-file-truename* *load-truename*)))
(%load-c-file it *compiler-state*)))) This was in compiler/libc-support.lisp. Note that this is SBCL specific due to symbols used. My guess is that it should be trivial to adapt to other CL implementations. Hope it helps. |
I tried loading a C file into SBCL 1.1.14-2 (debian, amd64), but got this error:
Do you have a hint for me, please?
The text was updated successfully, but these errors were encountered: