C 中的 Typedef 和结构

Typedef and struct in C

这两者有什么区别吗:

typedef struct ddwq{
    int b;
}ta;

typedef struct {
    int b;
}ta;

在前一种情况下,您可以将结构的类型引用为 struct ddwqta。在后一种情况下,您可以 将其引用为 ta,因为该结构没有标签。

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

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

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