两个可能的typedef struct语法选项,有什么不同?

Yuv*_*evy -1 c struct typedef

我想为链表定义一个结构,从接下来的两个选项中,其中一个主题更好?他们俩都会工作吗?有什么不同,你将使用哪一个?

typedef struct suppliers * SUP;
    typedef struct suppliers{
    int num;
    int moths;
    SUP next;
} su;
Run Code Online (Sandbox Code Playgroud)

其他选项是:

typedef supplier *suppliers
typedef struct supplier{
    int num;
    int moths;
    struct supplier *next;
} supplier;
Run Code Online (Sandbox Code Playgroud)

小智 5

我的首选版本:

struct supplier{
    int num;
    int moths;
    struct supplier *next;
};
Run Code Online (Sandbox Code Playgroud)

struct,enum或union上的typedef隐藏了有用的信息.

  • 第一个`struct supplier;`是不必要的.尽管如此,+1. (3认同)