Reputation: 13
I used enum to have boolean variables in C using following code in header file:
enum myBool { FALSE = 0, TRUE = 1}; typedef enum _myBool Bool;
then I defined some global Bool variables with: extern Bool low;
then when I tried to initialize the variables to false in another .c
file with Bool low = FALSE
I get the error variable 'low' has initializer but incomplete type.
How can I fix this? Thanks so much!!
Upvotes: 0
Views: 712
Reputation: 67721
then I defined some global Bool variables with:
extern Bool low
;
so you have declared it in the another file. otherwise you will get linker error
Upvotes: 0
Reputation: 4044
You have defined your enum as myBool
not _myBool
so you need to change
typedef enum _myBool Bool;
to
typedef enum myBool Bool;
Upvotes: 1