Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:23:27+00:00 2026-06-12T23:23:27+00:00

Let’s say you have an enumeration type with 50+ entries for its value. There

  • 0

Let’s say you have an enumeration type with 50+ entries for its value. There have been times where I’ve switch/cased an enum value with this amount of entries before, but only to check for, say, anywhere from 2 to 5 entries out of this.

For example, OpenGL sticks the majority of its enumerations in one enum type, referred to as GLenum. These values range from GL_VERTEX_SHADER to GL_STREAM_DRAW to GL_TRIANGLES to GL_ARRAY_BUFFER, etc.

As you can see, while these are related in terms of a bigger picture, the context in which they would be used does not relate with one another.

I’ve generated warnings on MinGW/GCC in Linux, where each warning accounts for every enum value listed in its type declaration. I’m not sure if this happens on VC++, but I figured I’d account for it anyway just in case.

In other words, the amount of warnings generated is TotalEnumValues - AmountOfCaseStatements for each enum value, providing not all enumerations have been accounted for in the statement itself, which can easily lead to 100+ compiler warnings if your enumeration type contains at least 100 entries.

I’ve often used if/else to accommodate this, but when checking enum values for more than just one entry (which is honestly quite rare, since the purpose of enums in general requires conditional logic to compliment it), I’ve always been prone to using switch/case, since I find it more aesthetically pleasing (even if it just compiles into an if/else statement anyway 😉 )

So, is this warning possible to turn off? If so, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:23:29+00:00Added an answer on June 12, 2026 at 11:23 pm

    Add a default: case that does nothing. The compiler will see that you are “handling” all the possibilities (thus removing the warning) but it won’t change at all the generated code if you don’t specify any action for it.


    To clarify: I’m talking about this:

    switch(a)
    {
    case CONSTANT_1:
            ...
        break;
    case CONSTANT_2:
            ...
        break;
    }
    

    vs this:

    switch(a)
    {
    case CONSTANT_1:
            ...
        break;
    case CONSTANT_2:
            ...
        break;
    default:
    }
    

    the second one does not modify at all the behavior, so the compiler shouldn’t change the generated code, but will tell it that you didn’t forget about the other (im)possible cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say you have a method that expects a numerical value as an argument.
Let's say I have a list containing some key-value pairs, and an array containing
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let's say I have a table with a Color column. Color can have various
Let's say that I have a SQLite database that I create in a separate
Let's say I have thousands of users and I want to make the passwords
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.