> Ok, here's a question for all you competent C coders out there. Let's say
> we have:
>
>
> struct A
> {
>
> //stuff
>
> struct B *Bstuff;
>
> }
>
> then we have a function something like this:
>
> int SomeWierdFunction( struct B *incoming )
> {
> //stuff...
> }
>
>
> Now my question... would there be any way to get a pointer to struct A
> inside SomeWierdFunction? Err... like the struct that actually contains
> incoming?
Sure, though you won't like it.
This isn't C++ though, so forgive me if I don't BiCapitalize all
my function names.
struct a {
struct b *bstruct;
}
struct b {
struct a *astruct; /* parent? */
}
struct a *mybfunction(struct b *data) {
return b->astruct;
}
That's right, if you want to backwards reference the structures
links, you have to provide a reference and make sure to set it correctly
at the appropriate time. Look at how two frequent lines, d->character and
ch->desc, interact in circle code in this manner.
There isn't any automatic 'this' or 'get_parent' or the sort.
PjD
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/11/01 PDT