cffi-ecl: c-inline-function-pointer-call bugfix
authorJuan Jose Garcia Ripoll <jjgarcia@users.sourceforge.net>
Thu, 22 Nov 2012 20:40:40 +0000 (21:40 +0100)
committerLuís Oliveira <loliveira@common-lisp.net>
Sun, 6 Jan 2013 20:45:42 +0000 (20:45 +0000)
The previous fix did not work with functions that return no values.
Surround the code with braces, so that the C compiler does not
complain about the extern declaration.

src/cffi-ecl.lisp

index 9f9500b..62a3c4e 100644 (file)
@@ -290,9 +290,9 @@ WITH-POINTER-TO-VECTOR-DATA."
                 ;; On AMD64, the following code only works with the extra
                 ;; argument ",...". If this is not present, functions
                 ;; like sprintf do not work
-                (format s "extern ~A ~A(~@[~{~A~^, ~}~]);
-@(return) = ~A(~A);"
+                (format s "{ extern ~A ~A(~@[~{~A~^, ~}~]); ~A~A(~A); }"
                         (ecl-type->c-type return-type) pointer types
+                        (if (eq return-type :void) "" "@(return) = ")
                         pointer
                         (subseq +ecl-inline-codes+ 0
                                 (max 0 (1- (* (length values) 3)))))))