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

  • Home
  • SEARCH
  • 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 6568455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:28:47+00:00 2026-05-25T14:28:47+00:00

The following text is an excerpt from C Programming Language, 2nd Edition , written

  • 0

The following text is an excerpt from C Programming Language, 2nd Edition, written by the creator of the C language (so I presume it is correct):

Although variables of enum types may be declared, compilers need not check that what you store in such a variable is a valid value for the enumeration.

I have some doubts:

  1. For what cases in the C language doesn’t the compiler check the value of an enum?
  2. enum constants are not checked for some reason. Why not? What are the reasons?
  3. Since enum is not checked by the compiler, is using enum error-prone? Please explain.
  • 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-05-25T14:28:47+00:00Added an answer on May 25, 2026 at 2:28 pm
    1. An enumeration is like a fancy integer, and it’s better than defining a whole load of constants or preprocessor macros as names for the constant values you want to store, because a compiler (or editor) can check that you’re using the right names and values to go with the right type. On the other hand, being just an int, there’s nothing stopping you putting in a value you didn’t make a name for, which is occasionally useful.

    2. They can’t be checked in every case. What if you add two numbers together to get the value that’s going to be put in the enum-typed variable? It could be any value, generated at runtime, so it can’t be checked (without a lot of overhead, at least).

    3. Everything in C is unsafe; there’s practically no feature which the compiler can totally prevent you from abusing. enums are safe because they are effective at preventing programmer error and confusion, not because they stop you doing something stupid.

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

Sidebar

Related Questions

I was reading the following text from Stanford's Programming Paradigms class , and I
the following text is an excerpt of oracle documentation Oracle® Database PL/SQL Language Reference
I have the following text from an academic course I took a while ago
I have the following text tooooooooooooon According to this book I'm reading, when the
I have following text in a file 23456789 When I tried to replace the
Consider I have the following text in a UILabel (a long line of dynamic
I have the following text: <i><b>It is noticeably faster.</b></i> <i><b>They take less disk space.</i>
Say I have the following text ..(content)............. <A HREF=http://foo.com/content >blah blah blah </A> ...(continue
If I have the following text in my Eclipse editor: Text Line 1 Text
I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>

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.