From owner-freebsd-arch@FreeBSD.ORG Thu Dec 23 04:34:06 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 BC00E16A4CE; Thu, 23 Dec 2004 04:34:06 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 010D643D3F; Thu, 23 Dec 2004 04:34:06 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.13.1/8.13.1) with ESMTP id iBN4VdVf029185; Wed, 22 Dec 2004 21:31:40 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 22 Dec 2004 21:31:47 -0700 (MST) Message-Id: <20041222.213147.93971875.imp@bsdimp.com> To: peadar.edwards@gmail.com From: "M. Warner Losh" In-Reply-To: <34cb7c84041222162210f14238@mail.gmail.com> References: <41C9C015.7050706@freebsd.org> <20041222.115155.71839775.imp@bsdimp.com> <34cb7c84041222162210f14238@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: grog@freebsd.org cc: PeterJeremy@optushome.com.au cc: scottl@freebsd.org cc: arch@freebsd.org 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: Thu, 23 Dec 2004 04:34:06 -0000 In message: <34cb7c84041222162210f14238@mail.gmail.com> Peter Edwards writes: : > : > Or better yet, just use the array of error values already compiled : > into the programs that strerror() formats for you (you don't need to : > use strerror, just sys_errlist[]). : : I'd dispute the "better yet": If used in code, "errno_t" is useful in : its own right. Even beyond the type safety, if used in a structure You don't get type safety from C enums. They are, at best, a lexically different #define. In C++ you have lots of other rules. : > (gdb) print *structptr : : Will print errno_t members properly, without requiring hints that : fields represent errno values, etc. (ie, it's a hint to the debugger : that something of type errno_t conveys more specific information than : a value between INT_MIN and INT_MAX.) : Although textual descriptions are better than the errno names to : users, "err_EBADF" means much more than "9" in a debug output to the : programmer running the debugger. : : Sorry for splitting hairs. (But the bikeshed should definitely be blue) I guess that's incompatible with what was said earlier in the thread. you'd have to assign the errno_t to the integer errno or the integer errno to an errno_t. That just doesn't work in C++. Warner