Stuart Sierra <[EMAIL PROTECTED]> writes: >> (setf *stack-pointer* (inc-pointer *stack-pointer* 1)) should >> work. You can abstract that with a simple macro: >> >> (defmacro incf-pointer (place &optional (offset 1)) >> `(setf ,place (inc-pointer ,place ,offset))) > > But won't that set the value that *STACK-POINTER* points to? In my > example, *STACK-POINTER* is not a Lisp object but a foreign global > variable accessed by name with DEFCVAR. As I understand CFFI's > :POINTER type, the above macro will modify the memory location that > PLACE points to but will not modify PLACE itself.
No because your *STACK-POINTER* is a symbol-macro that expands into (%var-accessor-*stack-pointer*) or something like that. Here's an example in cffi-tests (var_pointer is a foreign variable of type void*): CFFI-TESTS> (get-var-pointer '*var-pointer*) #.(SB-SYS:INT-SAP #X00396030) CFFI-TESTS> *var-pointer* #.(SB-SYS:INT-SAP #X00000000) CFFI-TESTS> (setf *var-pointer* (inc-pointer *var-pointer* 1)) #.(SB-SYS:INT-SAP #X00000001) CFFI-TESTS> (get-var-pointer '*var-pointer*) #.(SB-SYS:INT-SAP #X00396030) CFFI-TESTS> *var-pointer* #.(SB-SYS:INT-SAP #X00000001) *var-pointer* == (mem-ref (get-var-pointer '*var-pointer*) :pointer) HTH -- Luís Oliveira luismbo (@) gmail (.) com http://student.dei.uc.pt/~lmoliv/ _______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel