From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 13:00:51 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 B884916A4CE for ; Wed, 22 Dec 2004 13:00:51 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E9E543D45 for ; Wed, 22 Dec 2004 13:00:51 +0000 (GMT) (envelope-from peadar.edwards@gmail.com) Received: by wproxy.gmail.com with SMTP id 36so39363wra for ; Wed, 22 Dec 2004 05:00:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=PyeJSOn6vXTgWnxKf06fC9Pywn8PSd+2s+wNpVmVj3sU+FdbSq8NEddol72xj9W+ZWB4jlN5mVOrKvlwksnmmJFGYyh6QZHX4yt/FLpQWDAUyXCAd6Fo3vDkek/FDDXYkUZjHdQE/GStmcCIHCvKvDsBMPqjzMfcacxapdHtFws= Received: by 10.54.57.8 with SMTP id f8mr226813wra; Wed, 22 Dec 2004 05:00:50 -0800 (PST) Received: by 10.54.57.76 with HTTP; Wed, 22 Dec 2004 05:00:50 -0800 (PST) Message-ID: <34cb7c8404122205002bd7de18@mail.gmail.com> Date: Wed, 22 Dec 2004 13:00:50 +0000 From: Peter Edwards To: Peter Jeremy , Greg 'groggy' Lehey , FreeBSD Architecture Mailing List In-Reply-To: <20041222103844.GI801@straylight.m.ringlet.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041222010143.GS53357@wantadilla.lemis.com> <20041222090855.GO79646@cirb503493.alcatel.com.au> <20041222103844.GI801@straylight.m.ringlet.net> Subject: Re: Header files with enums instead of defines? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Peter Edwards 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 13:00:51 -0000 > The Single Unix Specification goes to great pains to repeat over and > over again that the error codes are 'symbolic constants', which IMHO > may be taken to mean either a #define'd macro or an enum value. > I, too, went to check with more than half a hunch that it would mandate > that the error codes be macros, but it turned out it doesn't :) But "errno" itself is "int", so even if the constants for the individual errno values were defined by an enumeration, that type information would be lost to the debugger when looking at errno itself, defeating the original benefit of having the symbolic names available in the debugger. As an alternative to Peter Jeremy's suggestion of using a GDB macro, you could, of course, define a type as: typedef enum { err_EPERM = EPERM, err_ENOENT = ENOENT, /* .... */ } errno_t Then within gdb: Breakpoint 1, main (argc=1, argv=0xbfbfe55c) at e.c:21 21 int rc = write(-1, "X", 1); (gdb) n 22 pause(); (gdb) p (errno_t)errno $1 = err_EBADF (gdb) (Note if you actually try this, you need to define at least one object of the errno_t type in your program to generate the type in the executable output.) That should work in other symbolic debuggers beyond gdb.