Reputation: 10144
I have a header file buildTree.h
and a C file buildTree.c
there is a struct typedef'd in the header file and I would like one of the struct members to be of an enum type
the header file code is:
#define TREE_ITEM_LIMIT 100
typedef enum pType {
none = 0,
bool = 1,
number = 2,
baud = 3
}pType;
typedef struct tree {
// 27 byte size struct
char longName [13];
char shortName [5];
char shortParent [5];
ptype parameterType;
void (* handler)(int);
}tree;
extern tree item[TREE_ITEM_LIMIT];
extern tree defaultValues;
If i then attempt to assign a value to a the parameterType member in the C file a get a bucket-load of errors that basically say my struct is pretty screwy. Whats really strange is that if I remove the assignment again, the errros dont go away the next time I compile! I have to remove the pType member from the struct, compile, then the errors are gone. If I add it back in again the errors stay gone until I try the assignment again...
Guessing Im not using the enum in the header correctly, but I cant see how...
EDIT: I did try commenting out the bool in the enum just in case that was playing up but no change
Upvotes: 1
Views: 6647
Reputation: 78923
naming a enumeration constant bool
is a particularly bad idea. This is reserved for "stdbool.h", and you may get plenty of problems with at. If this is what you are facing we can't say, since you gave us neither your compiler version, nor the error output.
Upvotes: 1
Reputation: 2097
If this is because you mistyped "pType" as "ptype" in your struct, the gods will punish you.
And next time, read the very first line of error output and fix that.
Upvotes: 2