C++ variable has initializer but incomplete type?
Get rid of struct
before item
, you've typedef'd it.
The problem is that
typedef struct { /* ... */ } item;
does not declare the type name struct item
, only item
. If you want to be able to use both names use
typedef struct item { /* ... */ } item;
typedef struct { ... } item
creates an unnamed struct
type, then typedef
s it to the name item
. So there is no struct item
- just item
and an unnamed struct
type.
Either use struct item { ... }
, or change all your struct item item1 = { ... }
s to item item1 = { ... }
. Which one you do depends on your preference.