It seems the enum constants are signed int as per C standard, please correct me if it is different.
Is there anyway to define an enum and typecast to other type say "unsigned int"?
In the following pseudo code, the enum variable "file1.status" was assigned with the return value of function "get_value", which is of type unsigned int.
Code:
typedef enum {
OPEN = 0,
CLOSE = 1,
SUCCESS = 3,
FAILURE = 4
} t_status;
struct file_status {
.
t_status status;
.
} file1;
unsigned int get_value()
{
unsigned int value;
.
.
return value;
}
void main()
{
.
file1.status = get_value();
.
}
I am getting Implicit conversion warning(unsigned int to signed int). Is it possible to fix this warning by typecasting the enum as unsigned int.