I need to do that in C.
I have a typedef struct with property x, and I will create many structs from the typedef struct. How can I refer to a given parent struct from the property. In reality, this x is a function, and the function needs to know what the other property, y, is.
How to do this in Javascript is
this.super
My code
#define NOTHING
typedef struct $ {
int (*x)(void);
int Y NOTHING;
} $;
int AddOneToParentY (void) {
//return This.super.Y +1; but in c instead of js
};
$ struct1 = {
.X = AddOneToParentY,
.Y = 3 NOTHING
};
$ struct2 = {
.X = AddOneToParentY,
.Y = 32 NOTHING
};
//When I call struct2.AddOneToParentY I should get 33
How to do this? Maybe something with POUND define macros?