Felix Kater <fk****@googlemail.comwrites:
is it valid to declare the variable 'e' of type 'my_enum' to later hold
the return value of function f2 -- or must e by of type int?
Felix
typedef enum{
a_my_enum,
b_my_enum,
c_my_enum
}my_enum;
my_enum f2(void){
return a_my_enum;
}
void f(void){
my_enum e; /* ok? or must e by of type int? */
e=f2();
}
Yes, that's fine, and clearer than declaring e to be of type int.
Integer types and enum types can be freely assigned to each other.
In fact, enum constants (a_my_enum et al) are actually of type int.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.