这是问题的概述(clang 抛出的错误代码):
标签的 typedef 和 struct def;
typedef struct tag {int tag;} tag;
Run Code Online (Sandbox Code Playgroud)
这工作得很好:
struct tag {int tag;} tag;
Run Code Online (Sandbox Code Playgroud)
而这些 typedef 错误之一:
typedef struct {int tag;} tag;
/*or*/
typedef struct tag {int tag;} tag;
/*and then this following code fails from either of the two
previous typedefs which the compiler errors about as being
redeclared as as different kind of symbol. Not allowed to share
typedef with object id:*/
tag tag;
Run Code Online (Sandbox Code Playgroud)
当指定相同名称的 typedef/tag 时,两个全局变量上的编译器错误:
/*error: redefinition of 'tag' as different …Run Code Online (Sandbox Code Playgroud)