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

Juan Jose Garcia-Ripoll worm at arrakis.es
Mon Mar 1 01:29:59 UTC 2004


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()"
>             :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'.

If only somebody took the work of documenting these features... :-)

Regards,

Juanjo





More information about the ecl-devel mailing list