Index: /trunk/ccl/library/parse-ffi.lisp
===================================================================
--- /trunk/ccl/library/parse-ffi.lisp	(revision 5717)
+++ /trunk/ccl/library/parse-ffi.lisp	(revision 5718)
@@ -18,4 +18,5 @@
 
 (defvar *parse-ffi-target-ftd* *target-ftd*)
+(defvar *ffi-struct-return-explicit* nil)
 (defvar *ffi-lisp-readtable* (copy-readtable nil))
 (defvar *ffi-ordinal* -1)
@@ -644,8 +645,11 @@
       (setq args (butlast args)))
     (when (ffi-record-type-p retval)
-      (push retval args)
-      (push `(:pointer ,retval) (ffi-function-arglist ffi-function))
-      (setf (ffi-function-return-value ffi-function) *ffi-void-reference*)
-      (setq retval *ffi-void-reference*))
+      (if *ffi-struct-return-explicit*
+        (format t "~& explicit struct return for ~s" ffi-function)
+        (progn
+          (push retval args)
+          (push `(:pointer ,retval) (ffi-function-arglist ffi-function))
+          (setf (ffi-function-return-value ffi-function) *ffi-void-reference*)
+          (setq retval *ffi-void-reference*))))
     (dolist (arg args) (ensure-referenced-type-defined arg))
     (ensure-referenced-type-defined retval)
@@ -712,4 +716,5 @@
          (*target-ftd* ftd)
          (*target-backend* backend)
+         (*ffi-struct-return-explicit* (getf (ftd-attributes ftd) :struct-return-explicit))
 	 (d (use-interface-dir dirname ftd))
 	 (interface-dir (merge-pathnames
