Is the sizeof(enum) == sizeof(int), always ?
- Or is it compiler dependent?
- Is it wrong to say, as complier are optimized for word lengths (memory alignment) ie y int is the word-size on a particular complier.Does it means that there is no processing penalty if i use enums, as they would be word aligned.
- Is it not better if i put all the return codes in an enum, as i clearly donot worry about the values it get, only the names while checking the return types. If this is the case wont #DEFINE be better as it would save memory.
What is the usual practise. I if i have to transport these return types over a network and some processing has to be done at the other end, what would u prefer enums/#defines/ const ints.
EDIT - Just checking on net, as complier dont symbolically link macros, how do people debug then, compare the integer value with the header file?
From Answers- I am adding this line below, as i need clarifications --
"So it is implementation-defined, and sizeof(enum) might be equal to sizeof(char), i.e. 1."
- Does it not mean that complier checks for the range of values in enums, and then assign memory. I dont think so, ofcourse i dont know :). Can some please show explain what is "might be"