[英]C90 and typedef
I had struct point {(...)};
我有
struct point {(...)};
defined.定义。 But with C90 it seems I have to do it with typedef.
但是对于 C90,似乎我必须使用 typedef 来完成。 How do I do this correctly?
我该如何正确地做到这一点?
typedef struct point {} point;
? ?
typedef struct {} point;
? ?
typedef struct point {};
? ?
You can do:你可以做:
typedef struct Point { ... } MyPoint;
and then use both kinds of declarations:然后使用两种声明:
struct Point p1;
MyPoint p2;
Both of these are correct:这两个都是正确的:
typedef struct point { /* ... */ } point;
typedef struct { /* ... */ } point;
The first version defines struct point
and then defines point
as an alias for it, while the second defines point
as an alias for an anonymous struct.第一个版本定义了
struct point
,然后将point
定义为它的别名,而第二个版本将point
定义为匿名结构的别名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.