Aurélien Aptel schrieb am So., 4. Okt. 2015 um 23:12 Uhr: > On Sun, Oct 4, 2015 at 9:47 PM, Philipp Stephani > wrote: > > Aurélien, is that something you agree with and could implement? > > I'm not sure I understood what you wanted.. I've commited this, but it > assumes Lisp_Object are the same size as pointers... > > commit 4c2813950d14fa2348e30ee94a4f3b022263e36d > Author: Aurélien Aptel > Date: Sun Oct 4 23:04:56 2015 +0200 > > use opaque struct emacs_value_tag instead of void* for emacs_value. > > diff --git a/src/emacs_module.h b/src/emacs_module.h > index c5ec347..b055547 100644 > --- a/src/emacs_module.h > +++ b/src/emacs_module.h > @@ -27,7 +27,7 @@ > > /* Current environement */ > typedef struct emacs_env_25 emacs_env; > -typedef void* emacs_value; > +typedef struct emacs_value_tag* emacs_value; > > enum emacs_type { > EMACS_FIXNUM, > diff --git a/src/module.c b/src/module.c > index 9bbb832..ab058bb 100644 > --- a/src/module.c > +++ b/src/module.c > @@ -24,6 +24,8 @@ > #include "dynlib.h" > #include "coding.h" > > +struct emacs_value_tag { Lisp_Object v; }; > + > void syms_of_module (void); > static struct emacs_runtime* module_get_runtime (void); > static emacs_env* module_get_environment (struct emacs_runtime *ert); > This is good (thanks!), but still assumes that sizeof(Lisp_Object) <= sizeof(void*) and that (Lisp_Object)((void *)0) is never a valid Lisp object, both of which are not provably true. To implement Daniel's approach you'll also have to change: static Lisp_Object value_to_lisp (emacs_value value) { return value->v; } static emacs_value lisp_to_value (Lisp_Object object) { emacs_value v = (emacs_value) malloc(sizeof v); // The allocation needs to be smarter, this example leaks memory. if (!v) return 0; v->v = object; return v; }