[Ecls-list] Tighter c/c++ integration, toplevel inline c/c++ code ???

Seth Burleigh seth at tewebs.com
Mon May 3 13:03:39 UTC 2010


ffi:clines introduces all code into the header file and does not inline
code into the c file. Can you declare c++ class methods in header files
and in general arbitrary c/c++ code? Can  you call obfuscated lisp
functions in the header file and are functions/classes defined in the
header file automatically exported (which isn't desirable)? (i dont
know, i dont usually do this)

But besides that, i tested your code and was wondering how i access the
c code from the REPL.

> (si:system "cat foo.lisp") (FFI:CLINES " int foo(int a, int b)
{ return a+b; }
")

;;compile file foo and then ....
(load "foo.fas")


(defun test () (let ((x (ffi:c-inline (1 2) (:int :int) :int
"foo(#0,#1)" :one-liner t)))
  (print x)))

TEST
UTILS2> (compile 'test)

;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;;   g++ "-I/usr/local/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-g -O2 -fPIC  -Dlinux -O -w -c "/tmp/ECL0028i12YJ.c" -o
"/tmp/ECL0028i12YJ.o"
/tmp/ECL0028i12YJ.c: In function ‘cl_lispunion* L1test()’:
/tmp/ECL0028i12YJ.c:16: error: ‘foo’ was not declared in this scope
;;; 
;;; Internal error:
;;;   ** (SYSTEM "g++ \"-I/usr/local/include/\"  -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -Dlinux -O -w -c
\"/tmp/ECL0028i12YJ.c\" -o \"/tmp/ECL0028i12YJ.o\"") returned non-zero
value 1
TEST
NIL
NIL










More information about the ecl-devel mailing list