Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经struct point {(...)};定义了。但是对于 C90,我似乎必须使用 typedef。我该如何正确地做到这一点?typedef struct point {} point;? typedef struct {} point;? typedef struct point {};?
struct point {(...)};
typedef struct point {} point;
typedef struct {} point;
typedef struct point {};
你可以做:
typedef struct Point { ... } MyPoint;
然后使用两种声明:
struct Point p1; MyPoint p2;
这两个都是正确的:
typedef struct point { /* ... */ } point; typedef struct { /* ... */ } point;
第一个版本定义struct point然后定义point为它的别名,而第二个版本定义point为匿名结构的别名。
struct point
point