[Ecls-list] can't compile with g++, and a question about returning a pointer from c-inline
Larry Clapp
larry at theclapp.org
Sun Feb 29 19:11:01 UTC 2004
Hi again,
I'm trying to interface with a C++ library. I have some sample code
that looks like
(clines "#include \"cxx-ffi-test.h\"")
(defvar *a*
(c-inline () () :int
"(int) new foo()"
:one-liner t))
(defun make-foo ()
(c-inline () () :int
"(int) new foo()"
:one-liner t))
(defun |foo::bar| (a-foo)
(c-inline (a-foo) (:int) :int
"((foo *) #0)->bar()"
:one-liner t))
; which all works fine, until ...
(defclass baz ()
((slot)))
I've set C:*CC* to "g++", and also diddled a bit with C::*CC-FLAGS*.
The compile line looks like
;;; Invoking external command: g++ -g -O2 -fomit-frame-pointer
-mcpu=athlon -march=athlon -fPIC -fstrict-aliasing -Dlinux
-I/big2/usr/src/qt-x11-free-3.3.0b1/include -DQT_NO_DEBUG -DQT_SHARED
-DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -O -I/usr/local/lib/ecl//h -w
-c ffi-test3.c -o ffi-test3.o
The .h file for the generated code has
extern cl_object clos_ensure_class();
g++ complains:
ffi-test3.h: In function `void init_FFI_TESTp(cl_lispunion*)':
ffi-test3.h:13: error: too many arguments to function
`cl_lispunion* clos_ensure_class()'
which I can fix by hand-editing the .h to say
extern cl_object clos_ensure_class(...);
and re-running the compile by hand, and then g++ doesn't gripe any
more (and gcc doesn't seem to mind, either). Ideally, of course, I'd
add a real signature, but this works for now.
I can't find where ecl emits the "clos_ensure_class()" line, or I'd
send a patch, not a bug report. :)
At least three other function prototypes also have this problem:
extern cl_object clos_slot_index_table();
extern cl_object clos_install_method();
extern cl_object cl_typep();
Can anyone suggest where I can patch the prototype generation?
Incidentally, you may've noticed me casting a pointer to an int:
(defun make-foo ()
(c-inline () () :int
"(int) new foo()"
:one-liner t))
Ick. Can anyone recommend a better alternative? I see that cl_object
has an ecl_foreign strucure, for user defined data, but I'm not sure
how to make use of it in the c-inline.
Thanks!
-- Larry Clapp
More information about the ecl-devel
mailing list