how to assign a value to a enum in C?

c, enums, lint, struct

Solution

Use your enum for what it was built for:

static Weekday weekday = {1,TUESDAY};

Lint is complaining because you have an enum, but are neither passing a symbol from the enum, nor a cast of a compatible type (such as `(ThreeDays)2`).

Use the enum symbols verbatim to avoid this warning from Lint.

Problem

I have a `enum` and a `struct` defined like this: ``` typedef enum { MONDAY = 1, TUESDAY, WEDNESDAY } ThreeDays; typedef struct { int hello; ThreeDays day; } Weekday; static Weekday weekday = { 1, 2}; ``` Then I got the following Error in lint: ``` Error 64: Type mismatch (initialization) (int/enum) ``` What is the reason of this Error? How can I correct it?

Original source