On Sat, 23 Oct 2004 12:38:06 -0400, Arthur J. O'Dwyer wrote:
So I can use &foo->b2 as the effective end of _b1tail?
Yes, but it is what Dennis Ritchie calls an "unwarrante d chumminess
with the implementation" .
Caveat: It depends what you mean by "use." For example, AFAIK it
invokes undefined behavior to write
((char*)&foo->b2)[-1] = 42; /* modify the "last" byte of |_b1tail| */
Maybe if Michael explains what he's really trying to do, a better (more
portable) solution will be reached.
Ok. The tail members are bitmaps that are different sizes depending on
needs. I have a struct with several of these object/bitmap pairs that
I initialize with a function like:
int
bar_init(struct bar *b, void *blim, float f)
{
memset(b, 0, blim - (void *)b);
b->blim = blim;
if (something_init (&b->something, f) == -1) {
return -1;
}
b->tail[0] = 0x01; /* don't use bit 0 */
return 0;
}
So when I call this initializer I need to know the end of the tail so
that my bitset rountines know where to stop. Rather than try to compute
this point I reasoned that provided the order of members is maintained
that the member following the tail is and effective blim.
if (bar_init(&foo->b1, &foo->b2, 1.1) == -1 ||
bar_init(&foo->b2, &foo->b3, 2.2) == -1 ||
bar_init(&foo->b4, foo + 1, 3.3) == -1) {
return -1;
}
So based on what you've said I think I'm ok.
Thanks,
Mike