When declaring an enum as shown below, do all C compilers set the default values as x=0
, y=1
, and z=2
on both Linux and Windows systems?
typedef enum {
x,
y,
z
} someName;
Yes. Unless you specify otherwise in the definition of the enumeration, the initial enumerator always has the value zero and the value of each subsequent enumerator is one greater than the previous enumerator.