
Is this program compliant?
Hi all,
Consider this program:
struct my_struct {
void (*my_func)(struct my_struct *);
unsigned char my_flag;
Quote:
};
void f (struct my_struct *a) {
a->my_flag = 1;
Quote:
};
int main (void) {
struct my_struct a;
a.my_func = &f;
a.my_flag = 0;
a.my_func (&a);
return 0;
Quote:
}
Is this code acceptable according to the C standard? What if the function f()
modified a->my_func instead of my_flag?
TIA,
Binand