Re: Header files with enums instead of defines?

From: M. Warner Losh (imp_at_bsdimp.com)
Date: 12/23/04

  • Next message: jsha: "FreeBSD's Visual Identity: Outdated?"
    Date: Wed, 22 Dec 2004 21:31:47 -0700 (MST)
    To: peadar.edwards@gmail.com
    
    

    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
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: jsha: "FreeBSD's Visual Identity: Outdated?"