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: David Brown
Subject: Re: [lwip-devel] [bug #35875] #define ⇒ enum?
Date: Mon, 19 Mar 2012 13:00:57 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0

On 18/03/2012 13:30, Simon Goldschmidt wrote:
Follow-up Comment #1, bug #35875 (project lwip):

I don't think so: the defines are used for good reason as enums are
sizeof(int) by default and we are using u8_t in many places.


#define'd integers are also "int" by default. So it only makes a difference if you use the enum types themselves to store the values, rather than storing them in u8_t types.

Using enum types for the values can cause warnings if you use a compiler and warnings that check for mixes between enumerated types and integers, or if you compile in forced C++ mode. So while using enum types is good in some ways, it may mean extra explicit casts to make the code compile cleanly in all cases.

An alternative might be to use "static const u8_t" values rather than "#define" macros, but again there could be problems with warning-free compiles if the values are used in several places.





reply via email to

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