Reputation: 153
I am trying to declare a struct, in myHeader.h I have defined the following struct type
typedef Books
{
int field1;
int field2;
}book;
When I am trying to declare a struct of type Books like this.
book b1; //in src.c that includes myHeader.h`
I am geting an error that says:
'book' : illegal use of this type as an expression.
Upvotes: 0
Views: 86
Reputation: 134396
During definition, using typedef
does not allow you to leave out the struct
keyword . You can use the new type without the struct
keyword.
Your
typedef Books
{
should be
typedef struct Books
{
and later, you can use
book b1;
as you like.
Upvotes: 2