From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 09:08:57 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 D4CBA16A4CE; Wed, 22 Dec 2004 09:08:57 +0000 (GMT) Received: from mail25.syd.optusnet.com.au (mail25.syd.optusnet.com.au [211.29.133.166]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E9B043D45; Wed, 22 Dec 2004 09:08:57 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) iBM98thj001700 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 22 Dec 2004 20:08:56 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])iBM98txP004497; Wed, 22 Dec 2004 20:08:55 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost)iBM98t4O004496; Wed, 22 Dec 2004 20:08:55 +1100 (EST) (envelope-from pjeremy) Date: Wed, 22 Dec 2004 20:08:55 +1100 From: Peter Jeremy To: "Greg 'groggy' Lehey" Message-ID: <20041222090855.GO79646@cirb503493.alcatel.com.au> References: <20041222010143.GS53357@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041222010143.GS53357@wantadilla.lemis.com> User-Agent: Mutt/1.4.2i cc: FreeBSD Architecture Mailing List 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 09:08:58 -0000 On Wed, 2004-Dec-22 11:31:43 +1030, Greg 'groggy' Lehey wrote: >Has anybody thought about replacing #defines with enums in header >files? It would make debugging a whole lot easier. Foe example, I'm >currently looking at a debug printout which contains: > > xerrno = 17, ... > xerrno = EEXIST, K&R2 states that errno is an "integer expression" and that the error values are "macros". I suspect POSIX and newer C standards say something similar. Also, the enum value name replacement would only occur if xerrno was of the appropriate enum type - which would make the code non-portable. An alternative suggestion for you: Write a gdb macro which takes an int and prints it as an errno. Something like a shorthand version of: print (enum { EPERM=1, ENOENT=2, ..., EILSEQ=86})xerrno should work. You would probably write a [insert scripting language of choice] script to convert into the appropriate gdb macro. -- Peter Jeremy