1 2 3 4 5 | struct sample { int member_int; char *member_str; void (*member_fun)(void); }; |
1 2 3 4 5 | struct sample inst_c99 = { .member_int = 78, .member_str = "iloveqhq", .member_fun = real_fun, }; |
1 2 3 4 5 | struct sample inst_gcc = { member_int: 76, member_str: "zhaoway", member_fun: real_fun, }; |
1 2 3 4 5 6 7 8 9 | #define MEMBER_INT 0 #define MEMBER_STR "" #define MEMBER_FUN NULL #define SAMPLE_INITIALIZER { \ MEMBER_INT, \ MEMBER_STR, \ MEMBER_FUN, \ } |
1 2 3 4 5 6 7 | #undef MEMBER_INT #define MEMBER_INT 12 #undef MEMBER_STR #define MEMBER_STR "trtr" #undef MEMBER_FUN #define MEMBER_FUN real_fun struct sample inst_def = SAMPLE_INITIALIZER; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |