سؤال
I had struct point {(...)};
defined. But with ANSI standards 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.
لا تنتمي إلى StackOverflow