-
dumb struct question
Suppose I define a structure like this
Code:
typedef struct foo {
/* some data */
} foo_t;
To be used 'XXX' times in another structure. What is different between:
Code:
typedef struct yyy {
foo_t name[XXX];
} yyy_t;
and..
Code:
typedef struct yyy {
struct foo name[XXX];
} yyy_t;
?? If they are the same, which is preferred and why?
Thanks!
-
They are effectively the same, and since the typedef name is provided, you might as well use it. The difference comes when you want to refer to struct foo from within struct foo's definition: since the typedef exists outside of the definition of struct foo, you must then use struct foo, not foo_t (unless you write a separate typedef before the definition of struct foo).
-