Date: Thu, 17 Oct 1996 19:21:48 +1000 From: Andrew McRae <amcrae@cisco.com> To: phk@freebsd.org, hackers@freebsd.org Subject: Re: enum considered bad ? Message-ID: <199610170921.TAA25379@metaplex-ss10.cisco.com>
next in thread | raw e-mail | index | archive | help
phk@critter.tfs.com (Poul-Henning Kamp): > > I've noticed that "enum" is hardly ever used in C programs, is this > because people consider it a bad idea or because they havn't really > got the swing of it ? Can be historical in nature. Enums came in around the same time that structure copying came in, so the earliest kernels and user-land code did not have any enum code in them. In kernel stuff, one reason why #define stuff is preferred over enums is because you can use them in asm files. Also, people sometimes like to overload variables with bit masks as well as enumeration. I use enums where I can, and they are encouraged here at cisco. I prefer them because the compiler can be a little stricter with type checking and switch warnings etc., but it is surprising how many times you want to store those numbers in a char (so you can't declare the variable as an enum) or get at them in an assembler routiner. > Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. Cheers, Andrew McRae (cisco Core Down Under).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610170921.TAA25379>