anchor.diff:                                                          (foreign-type fun))))))))
   
   (defmacro define-cfun (name-or-function &optional (package *package*))
  -  (let ((fun (find-function name-or-function)))
  -    (with-slots (name type c-symbol fields) fun
  -      (let ((fun-name (intern (symbol-name name) package))
  -            (params (mapcar #'foreign-type-name fields)))
  -        (with-gensyms (!fun !fields rest)
  -          `(defmacro ,fun-name (,@params ,@(when (foreign-function-variadic-p fun) `(&rest ,rest)))
  -             (let ((,!fun (find-function ',name-or-function)))
  -               (with-slots ((,!fields fields)) ,!fun
  -                 (foreign-to-ffi
  -                  (and (car ,!fields) (foreign-type (car ,!fields)))
  -                  (and (car ,!fields) (foreign-type-name (car ,!fields)))
  -                  (list ,@params)
  -                  ,!fields
  -                  (make-foreign-funcall ,!fun ,(when (foreign-function-variadic-p fun) rest)))))))))))
  +  (when-let ((fun (find-function name-or-function)))
  +    (with-wrap-attempt ("define C function ~S" name-or-function) name-or-function
  +      (with-slots (name type c-symbol fields) fun
  +        (let ((fun-name (intern (symbol-name name) package))
  +              (params (mapcar #'foreign-type-name fields)))
  +          (with-gensyms (!fun !fields rest)
  +            `(defmacro ,fun-name (,@params ,@(when (foreign-function-variadic-p fun) `(&rest ,rest)))
  +               (let ((,!fun (find-function ',name-or-function)))
  +                 (with-slots ((,!fields fields)) ,!fun
  +                   (foreign-to-ffi
  +                    (and (car ,!fields) (foreign-type (car ,!fields)))
  +                    (and (car ,!fields) (foreign-type-name (car ,!fields)))
  +                    (list ,@params)
  +                    ,!fields
  +                    (make-foreign-funcall ,!fun ,(when (foreign-function-variadic-p fun) rest))))))))))))
   
   (defmacro define-cextern (name &optional (package *package*))
  -  (let* ((*package* package)
  -         (extern (find-extern name))
  -         (ptr-or-error
  -           `(or (cffi-sys:%foreign-symbol-pointer ,(foreign-symbol-c-symbol extern) :default)
  -                (error "Foreign extern symbol not found: ~S" ',name))))
  -    (if (foreign-scalar-p (foreign-type extern))
  -        `(define-symbol-macro ,name
  -             (cffi-sys:%mem-ref ,ptr-or-error
  -                                ,(basic-foreign-type (foreign-type extern))))
  -        `(define-symbol-macro ,name ,ptr-or-error))))
  +  (with-wrap-attempt ("define extern ~S" name) name
  +    (let* ((*package* package)
  +           (extern (find-extern name))
  +           (ptr-or-error
  +            `(or (cffi-sys:%foreign-symbol-pointer ,(foreign-symbol-c-symbol extern) :default)
  +                 (error "Foreign extern symbol not found: ~S" ',name))))
  +      (if (foreign-scalar-p (foreign-type extern))
  +          `(define-symbol-macro ,name
  +               (cffi-sys:%mem-ref ,ptr-or-error
  +                                  ,(basic-foreign-type (foreign-type extern))))
  +          `(define-symbol-macro ,name ,ptr-or-error)))))
   
     ;; Bitfields
  
positive.code:   `(cffi-sys:%defcallback
      ,name ,(basic-foreign-type return-type)
      ,(mapcar #'car lambda-list)
      ,(mapcar (lambda (x) (basic-foreign-type (ensure-type (cadr x)))) lambda-list)
      (progn ,@body)
      :convention :cdecl))
  
  
negative.code:   ((variadic-p :initarg :variadic-p
                 :initform nil :accessor foreign-function-variadic-p)))
  
  (defun find-type (typespec)
    (if (keywordp typespec)
        typespec
        (gethash typespec *foreign-types*)))
  
  (defun undefined-enum-value (value)
    (autowrap-continuable-error "Undefined enum value: ~S" value))
  
  