[Ecls-list] Wrapping C++ constants...

Dietrich Bollmann dietrich at formgames.org
Fri Jul 12 02:56:05 UTC 2013


Hi Matt,

Thank you!

So the following works:

(let () (defconstant +xy-plane+ (ffi:c-inline () () :pointer-void "(void *)
&ON_xy_plane" :one-liner t)))

Here - just for reference - a link to the file contrib/sockets/sockets.lisp:


http://sourceforge.net/p/ecls/ecl/ci/master/tree/contrib/sockets/sockets.lisp

And another simple example with context:

Example:

  (ffi:clines "#define SOME_CONSTANT 123")
  (let () (defconstant +some-constant+ (ffi:c-inline () () :int
"SOME_CONSTANT" :one-liner t)))

Usage:

  (format t "+some-constant+: ~a~%" +some-constant+)

Output:

  +some-constant+: 123

I summarized your comments on the following page:
http://formgames.org/wiki/ECL/Wrapping_constants

Does it make sense to copy this / parts of it into the ECL Wiki?

All the best,

Dietrich




On Fri, Jul 12, 2013 at 12:35 AM, Matthew Mondor
<mm_lists at pulsar-zone.net>wrote:

> On Thu, 11 Jul 2013 20:26:11 +0900
> Dietrich Bollmann <dietrich at formgames.org> wrote:
>
> > I want to wrap a pointer to a C++ constant into a lisp constant.
> >
> > The following
> >
> >   (defconstant +xy-plane+
> >     (ffi:c-inline () () :pointer-void "(void *) &ON_xy_plane" :one-liner
> t))
> >
> > results in this error:
> [...]
> >
> > But this - at least to me - looks kind of unnecessarily cumbersome...
> >
> > Is there a better way to wrap a pointer to a constant from lisp?
>
> It's necessary to wrap those DEFCONSTANT inside a LET block so they are
> no longer top-level, see how contrib/sockets/sockets.lisp in the ECL
> source tree does it for instance.
> --
> Matt
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130712/a9ea91ea/attachment.html>


More information about the ecl-devel mailing list