Re: enum safety



Sard wrote:
Hi,

Page 39 K&R2 says

'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'

This is why (in my opinion) enums are horribly broken in C.

int main ()
{
enum colours purple =c ;

c is a pointer, enums are integer types.

You would get the same diagnostic with

int n = c;

--
Ian Collins.
.



Relevant Pages

  • enum safety
    ... 'Although variables of enum types may be declared, compilers need not ...
    (comp.lang.c)
  • Re: Using Enum type as Webservice Parameter
    ... generally enum types are represented by xsd enumeration simple type like below: ... \par Public Enum TestEnum As Integer ... \par This posting is provided "AS IS" with no warranties, and confers no rights. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Enum Problems
    ... passing enum types - during wsdl and everywhere on its way it is passed ... as string. ... this enum type to webservice. ... public enum StatusType ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: forward declaration of an enumerated type
    ... No matter struct and enum types can be forwarded declared. ... void print(X& x, ENU enu); ...
    (microsoft.public.vc.language)
  • Re: C DLL to C# (types exporting)
    ... I've got a DLL written in C convention. ... There're a few of enum types that ... Make your C source file look like so: ... enum anenum { ...
    (microsoft.public.dotnet.languages.csharp)