lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] [bug #35875] #define ⇒ enum?


From: Bill Auerbach
Subject: Re: [lwip-devel] [bug #35875] #define ⇒ enum?
Date: Mon, 19 Mar 2012 17:42:07 -0400

>-----Original Message-----
>From: address@hidden
>[mailto:address@hidden On
>Behalf Of David Empson
>Sent: Monday, March 19, 2012 5:18 PM
>To: lwip-devel
>Subject: Re: [lwip-devel] [bug #35875] #define ⇒ enum?
>
>One argument against using enums (admittedly weak): some compilers,
>including one we are using, implement enums as unsigned instead of
>signed integers, in violation of C standards. Attempting to declare a
>negative enum value produces an error. I generally prefer to use enums
>for named constants, but with this compiler I've had to use #define for
>negative values.

David,

You mean this is an error:

enum someEnum { Val1 = 1, Val2 = -1 };

What about:

enum someEnum { Val1 = 1, Val2 = -1U };

or

enum someEnum { Val1 = 1, Val2 = (unsigned) -1 };

That reall is an odd thing for a compiler - I could see using unsigned if no
member is < 0 but to default to unsigned isn't good.  And it's really easy
to resolve if the compiler is still being maintained.

Bill




reply via email to

[Prev in Thread] Current Thread [Next in Thread]