开发者

C90 and typedef

I h开发者_StackOverflow中文版ad struct point {(...)}; defined. But with C90 it seems I have to do it with 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜