здесь очень упрощенный код проблемы, который у меня есть:
enum node_type {
t_int, t_double
};
struct int_node {
int value;
};
struct double_node {
double value;
};
struct node {
enum node_type type;
union {
struct int_node int_n;
struct double_node double_n;
};
};
int main(void) {
struct int_node i;
i.value = 10;
struct node n;
n.type = t_int;
n.int_n = i;
return 0;
}
И я не знаю, что это:
$ cc us.c $ cc -std=c99 us.c us.c:18:4: warning: declaration does not declare anything us.c: In function ‘main’: us.c:26:4: error: ‘struct node’ has no member named ‘int_n’
Использование GCC без -std опции компилирует код выше без проблем (и аналогичный код работает очень хорошо), но кажется, что c99 не разрешает эту технику. Почему это так, и возможно ли сделать c99 (или c89, c90) совместимым? Спасибо.