enum type checking and switches question

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Fri Oct 27 00:29:49 AEST 1989


  You have to know the history of enum to understand why it works as
poorly as it does. Someone was out of space for #defined values in their
preprocessor, and so added enum to get more space in a diferent symbol
table. That's why you can use the name of an enum value as if it was an
ordanary int, because it was intended to work that way.

  This was discussed at one of the early meetings of X3J11 (I was on for
just over two years) and because of "existing practice" it was agreed
that adding a real enum type with range checking, etc, was not
practical. enum can add clarity to reading the code, but it missed its
chance to allow the compiler to do more runtime checking.

  Makinging this work in a range checking manner would break a lot of
programs, but I wish there was a way. Your compiler is not broken for
failing to perform the checks, that's the way it works.

-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list