Using typedef with an instance declaration. Wiki error?

老子叫甜甜 提交于 2019-12-07 20:31:58

问题


In accordance to this Wiki page, it is possible to write the following structure:

typedef struct my_struct {
    int integer;
} my_struct_t instance;

K&R do not mention this in "C Proglamming Language". Compiler also returns error during the compilation:

error: expected =, ,, ;, asm, or __attribute__ before instance

Is it a Wiki error or I do something stupid?


回答1:


You misunderstand the page. You can either make a typedef, or define an instance of the structure, but not both.

It might be clearer if you read the whole page and not only syntax block at the top.



来源:https://stackoverflow.com/questions/16415734/using-typedef-with-an-instance-declaration-wiki-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!