Ryan - <br><br>I am forwarding this to CFFI-devel and Martin directly (though I'm pretty sure he's subscribed to cffi-devel). Can you please send future messages to cffi-devel? I'm not sure many people read the github mailing list; this issue should get wider visibility. Thanks.<br>
<br>Liam<br><br><div class="gmail_quote">On Mon, Feb 20, 2012 at 12:02 PM, Ryan Pavlik <span dir="ltr"><<a href="mailto:reply%2Bi-1614209-ba246666762196459413560690eb7d3a39c7c7ee-838019@reply.github.com">reply+i-1614209-ba246666762196459413560690eb7d3a39c7c7ee-838019@reply.github.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure what you mean. It doesn't really matter that a pointer is aggregate or not. The goal is to get at the Nth member of an array-of-something. In the case of scalar C types, you're getting the value; in the case of structs it's far more useful to get a pointer, because you probably only want a single value out of the struct, or to **put a value into the struct**. (The `setf` form works for scalars in the latter case, but not for "member-of-struct-of-index-N"... you most likely want the pointer in these cases.)<br>
<br>
It also occurred to me after posting that there is no difference between `(mem-aref ptr '(:pointer (:struct foo)) N)` and just simply `(mem-aref ptr :pointer N)` ... both return a pointer value as if `ptr` is a `void *ptr[k]`.<br>
<br>
A struct of more bytes works the same way:<br>
<br>
```<br>
(cffi:defcstruct my-struct<br>
(x :long)<br>
(y :long)<br>
(x :long)<br>
(t :long))<br>
<br>
...<br>
<br>
Old-ref style:<br>
ptr : #.(SB-SYS:INT-SAP #X7FFFEEFC7FB8)<br>
aref: #.(SB-SYS:INT-SAP #X7FFFEEFC7FD8)<br>
New-ref style:<br>
ptr : #.(SB-SYS:INT-SAP #X7FFFEEFC7FB8)<br>
aref: (T 0 Y 0 X 0)<br>
New-ref with :pointer style:<br>
ptr : #.(SB-SYS:INT-SAP #X7FFFEEFC7FB8)<br>
aref: #.(SB-SYS:INT-SAP #X00000000)<br>
```<br>
<br>
Note that on my system, a pointer is 8 bytes, not 4. This is why I initially found the problem, when trying to access an array of points defined by 2 short; each member is 4 bytes, and it was giving offsets to `sizeof(void*)`.<br>
<br>
---<br>
<div class="im">Reply to this email directly or view it on GitHub:<br>
</div><a href="https://github.com/cffi/cffi/pull/2#issuecomment-4057418" target="_blank">https://github.com/cffi/cffi/pull/2#issuecomment-4057418</a><br>
</blockquote></div><br>