Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Dec 2004 21:31:47 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        peadar.edwards@gmail.com
Cc:        arch@freebsd.org
Subject:   Re: Header files with enums instead of defines?
Message-ID:  <20041222.213147.93971875.imp@bsdimp.com>
In-Reply-To: <34cb7c84041222162210f14238@mail.gmail.com>
References:  <41C9C015.7050706@freebsd.org> <20041222.115155.71839775.imp@bsdimp.com> <34cb7c84041222162210f14238@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <34cb7c84041222162210f14238@mail.gmail.com>
            Peter Edwards <peadar.edwards@gmail.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041222.213147.93971875.imp>