[Ecls-list] Handling C/C++ pointers in lisp code (Was "can't compile with g++")

Larry Clapp larry at theclapp.org
Sat Mar 6 15:43:00 UTC 2004


On Mon, Mar 01, 2004 at 10:16:58AM +0100, Juan Jose Garcia-Ripoll wrote:
> On Monday 01 March 2004 10:02, Juan Jose Garcia-Ripoll wrote:
> > And if you want better "typechecking", use a meaningful name for
> > your type.  For instance a symbol, instead of "Cnil" up there.
> 
> For got the following tip: you can embed lisp objects in your C/C++
> code
> 
> >     (defun make-foo ()
> >        (c-inline () () :object
> > 	   "ecl_make_foreign(@BAR, 0, new foo())"
> >
> > 	   :one-liner t))
> >
> >     (defun |foo::bar| (a-foo)
> >       (c-inline (a-foo) (:object) :int
> >             "((foo *)ecl_foreign_data_safe(#0, @BAR))->bar()"

Note: Actual function name in CVS (as of March 6, 2004) is
ecl_foreign_data_pointer_safe.

> >             :one-liner t))
> 
> Notice that after the '@', there should be a valid lisp object. If
> you guess you will have problems with some characters of your C/C++
> code, use @(quote ...) and place all your data within the
> parenthesis, after 'quote'.

-- Larry Clapp





More information about the ecl-devel mailing list