This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: enumeration value ... not handled in switch


Daniel Brockman <daniel@brockman.se> writes:

> Consider the following code:
>
>    struct fruit
>    {
>      enum { APPLE, MELON, ORANGE } type;
>      ...
>    } fruit;
>
>    ...
>
>    switch (fruit.type)
>      {
>        case APPLE:
>          ...; break;
>        case MELON:
>          ...; break;
>        case ORANGE:
>          ...; break;
>      }
>
> Here, as soon as another value is added to the enum, gcc will warn
> about the switch statement not handling it.
>
> But what if `fruit_type' is neither `APPLE' nor `ORANGE'?

What I really meant to say here was the following:

But what if `fruit_type' is neither `APPLE', `MELON', nor `ORANGE'?


Apologies,

-- 
Daniel Brockman <daniel@brockman.se>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]