Closed GoogleCodeExporter closed 8 years ago
What would you like to use this for?
Original comment by aggraef@gmail.com
on 22 Jul 2010 at 8:46
Several graph and network API routines from the pure-glpk package work with
with memory blocks used for storing selected data items. The routines require
input of the block's total size and of offsets of individual items to be
stored in the block. The items can be of various data types.
The easiest way to implement this is using structs. The required sizeof
function is already in the place but ofsetoff is missing. Calculating the
offsets manually is neither safe nor convenient.
Original comment by jiri.spitz@gmail.com
on 22 Jul 2010 at 9:04
Maybe it would be more appropriate to define the offsetof function on the
struct type rather than on the struct itself.
Original comment by jiri.spitz@gmail.com
on 22 Jul 2010 at 9:16
Ok, I see why this is useful now. :) Please fell free to commit it when you're
ready and also update the docs accordingly.
Concerning the argument: Why not just make offsetof take either a struct or a
struct type as argument?
Original comment by aggraef@gmail.com
on 22 Jul 2010 at 12:51
Fixed in rev. 3521. The function accepts both struct types and struct
instances. Since the function 'sizeof' is complementary to 'offsetof' I changed
it to accept both argument types as well.
I changed the comments in ffi.pure, the README is currently too brief.
Original comment by jiri.spitz@gmail.com
on 22 Jul 2010 at 11:19
Great, many thanks! A forward declaration was still needed to make pure -w
happy, I added that in r3522.
Yeah, the README definitely needs some love, but I guess that people will find
their way reading the comments in ffi.pure.
Original comment by aggraef@gmail.com
on 22 Jul 2010 at 11:45
Original issue reported on code.google.com by
jiri.spitz@gmail.com
on 21 Jul 2010 at 11:06Attachments: