svn commit: r312296 - in head: lib/libc/sys sys/kern sys/netinet sys/netinet6 sys/sys tools/regression/sockets/udp_pingpong tools/regression/sockets/unix_cmsg

Eric van Gyzen vangyzen at FreeBSD.org
Tue Jan 17 19:37:36 UTC 2017


On 01/17/2017 11:48, Benjamin Kaduk wrote:
> On Tue, Jan 17, 2017 at 10:57 AM, Ian Lepore <ian at freebsd.org
> <mailto:ian at freebsd.org>> wrote:
> 
>     In my experience, enums are a superior way to define integer constants
>     (compared to #define), but they are pure poison as variable types in
>     APIs and structures because their size is a compiler implementation
>     choice.
> 
> 
> Well, to some extent. For example, the amd64 sysV ABI says that enum
> types are signed fourbyte, with a footnote that "C++ and some
> implementations of C permit enums larger than an int. The underlying
> type is bumped to an unsigned int, long int or unsigned long int, in
> that order."

And in C++11 and later, you can specify the exact type:

enum color
#if defined(__cplusplus) && __cplusplus >= 201103L
	: int
#endif
{
	blue,
	...

Eric


More information about the svn-src-all mailing list