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.
精彩评论