Stelian Ionescu <sione...@cddr.org> writes: > On Thu, 2012-04-19 at 14:46 +0000, Stas Boukarev wrote: >> Luís Oliveira <luismbo <at> gmail.com> writes: >> >> > >> > On Thu, Apr 19, 2012 at 2:50 PM, Stelian Ionescu <sionescu <at> cddr.org> >> wrote: >> > > (with-foreign-object (p '(:struct timespec) 2) >> > > (mem-aref p '(:struct timespec) 1)) >> > > >> > > In order not to break existing code [...] >> > >> > Existing code will not have this (:struct foo) syntax because it was >> > introduced by the libffi merge. (mem-aref p 'timespec 1) should >> > exhibit backwards-compatible behaviour. >> Turns out, the problem is not with mem-aref, but with the mem-aref compile- >> macro. It binds *parse-bare-structs-as-pointers* to T, whereas mem-aref >> function >> doesn't, this affects the result of foreign-type-size. > > Actually it's mem-aref that should bind *parse-bare-structs-as-pointers* > to T, so I pushed the fix
This breaks it. (cffi:defcstruct foo (a :short) (b :short)) ;; After binding *parse-bare-structs-as-pointers* to T in the mem-aref function: (cffi:with-foreign-object (var 'foo 20) (let ((type 'foo)) (cffi:mem-aref var type))) ;; new cffi => #.(SB-SYS:INT-SAP #X00000000) ;; old cffi and new with a constant type return an expected address ;; Previous problems I originally described: (cffi:with-foreign-object (var 'foo 2) (- (cffi-sys:pointer-address (cffi:mem-aref var 'foo 1)) (cffi-sys:pointer-address (cffi:mem-aref var 'foo 0)))) ;; old cffi => 4 ;; new cffi => 8 ;; With mem-aptr works as expected: (cffi:with-foreign-object (var 'foo 2) (- (cffi-sys:pointer-address (cffi:mem-aptr var 'foo 1)) (cffi-sys:pointer-address (cffi:mem-aptr var 'foo 0)))) ;; new cffi => 4 -- With best regards, Stas. _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel