C中的Typedef和struct

C中的Typedef和struct,c,struct,typedef,C,Struct,Typedef,这两者之间有什么区别吗: typedef struct ddwq{ int b; }ta; typedef struct { int b; }ta; 在前一种情况下,可以将结构的类型引用为struct ddwq或ta。在后一种情况下,由于结构没有标记,因此只能将其引用为ta 如果结构包含指向自身的指针,则需要第一种情况,例如: typedef struct ddwq{ int b; struct ddwq *p; }ta; 类型名ta在结构内部不可见,因此结

这两者之间有什么区别吗:

typedef struct ddwq{
    int b;
}ta;

typedef struct {
    int b;
}ta;

在前一种情况下,可以将结构的类型引用为
struct ddwq
ta
。在后一种情况下,由于结构没有标记,因此只能将其引用为
ta

如果结构包含指向自身的指针,则需要第一种情况,例如:

typedef struct ddwq{
    int b;
    struct ddwq *p;
}ta;

类型名
ta
在结构内部不可见,因此结构必须有标记名才能引用自身。

一些旧的调试器无法使用匿名结构,因此即使代码从未使用标记,也有助于使用标记。