struct foo {
int a;
int b;
int c;
}__attribute__((packed));
void print(foo* f) {
int *p = f;
int i;
for (i=0; i<sizeof(foo)/sizeof(int); i++) {
printf("%d,",p[i]);
}
}
You start with a collection of obj_type pointers and cast them to the appropriate pointer type when you have identified the actual contained struct. Useful if you need to have a heterogeneous list of things.
Or to use an example the author didn't regret: