Can I name a variable with the same name as a typedef'd structure name?

后端 未结 5 1046
北荒
北荒 2020-12-20 14:14

Here is the structure declare code.

struct list_el {
    int val;
    struct list_el * next;
};

typedef struct list_el item;

And when I

5条回答
  •  爱一瞬间的悲伤
    2020-12-20 14:58

    you should use -Wshadow when you compile you code. Then, gcc will tell you where you are wrong. :-) like follows:
    declaration of ‘item’ shadows a global declaration [-Wshadow]

提交回复
热议问题