From owner-freebsd-hackers Thu Oct 17 02:22:58 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id CAA18960 for hackers-outgoing; Thu, 17 Oct 1996 02:22:58 -0700 (PDT) Received: from metaplex-ss10.cisco.com (metaplex-ss10.cisco.com [171.69.176.7]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id CAA18955; Thu, 17 Oct 1996 02:22:52 -0700 (PDT) Received: (amcrae@localhost) by metaplex-ss10.cisco.com (8.6.8+c/8.6.5) id TAA25379; Thu, 17 Oct 1996 19:21:48 +1000 Date: Thu, 17 Oct 1996 19:21:48 +1000 From: Andrew McRae Message-Id: <199610170921.TAA25379@metaplex-ss10.cisco.com> To: phk@freebsd.org, hackers@freebsd.org Subject: Re: enum considered bad ? Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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).