Reputation: 125
I want to define bool type (enum format)
typedef enum bool_enum {
false,
true,
} bool;
But is returning the folowing error in the compilation
error: expected identifier before numeric constant
false,
error: expected ‘;’, identifier or ‘(’ before ‘_Bool’
} bool;
What is wrong in the enum type definition?
Upvotes: 2
Views: 1323
Reputation: 400139
You probably have <stdbool.h>
included, which typically contains:
#define true 1
#define false 0
So your names are not good, they collide with standard headers (which of course also define the name bool
itself).
Drop this, and just use <stdbool.h>
would be my advice.
Upvotes: 3