Anonymous union within struct not in c99?

后端 未结 7 1029
时光说笑
时光说笑 2020-11-28 11:40

here is very simplified code of problem I have:

enum node_type {
    t_int, t_double
};

struct int_node {
    int value;
};

struct double_node {
    double valu         


        
相关标签:
7条回答
  • 2020-11-28 12:25

    Anonymous unions are a GNU extension, not part of any standard version of the C language. You can use -std=gnu99 or something like that for c99+GNU extensions, but it's best to write proper C and not rely on extensions which provide nothing but syntactic sugar...

    Edit: Anonymous unions were added in C11, so they are now a standard part of the language. Presumably GCC's -std=c11 lets you use them.

    0 讨论(0)
提交回复
热议问题