From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 02:06:36 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11B7816A4CE; Wed, 22 Dec 2004 02:06:36 +0000 (GMT) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9803543D55; Wed, 22 Dec 2004 02:06:35 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.13.0/8.13.0) with ESMTP id iBM26XJK029844; Tue, 21 Dec 2004 21:06:34 -0500 Mime-Version: 1.0 Message-Id: In-Reply-To: <20041222010143.GS53357@wantadilla.lemis.com> References: <20041222010143.GS53357@wantadilla.lemis.com> Date: Tue, 21 Dec 2004 21:06:32 -0500 To: "Greg 'groggy' Lehey" , FreeBSD Architecture Mailing List From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) Subject: Re: Header files with enums instead of defines? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 02:06:36 -0000 At 11:31 AM +1030 12/22/04, Greg 'groggy' Lehey wrote: > >To find out what that means, I need to go to >/usr/src/include/sys/errno.h and look for 17. I find: > >#define EEXIST 17 /* File exists */ > >If we were to change this to > >enum EEXIST = 17; /* File exists */ > >I'd then be able to see: > > xerrno = EEXIST, > >That makes debugging a whole lot easier. About the only down side >I can see is that you can't #undef an enum. Is this a big deal? You also can't #ifdef an enum. You also can't: enum EEXIST = 17; I'm not a C expert, but you need something more like: enum ERRVALS { EEXIST = 17 }; At least that compiles for me. Some C compilers (irix) will also complain if you assign an enum-value (such as EEXIST) to a variable which isn't of the same enum-type (eg: ERRVALS). So, in those compilers you would have to define 'xerror' as 'enum ERRVALS xerror', not 'int xerror'. I think that isn't part of the C standard, but on occassion that check has found a few bugs for me... -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu