Re: Header files with enums instead of defines?

From: Peter Jeremy (PeterJeremy_at_optushome.com.au)
Date: 12/22/04

  • Next message: Peter Pentchev: "Re: Header files with enums instead of defines?"
    Date: Wed, 22 Dec 2004 20:08:55 +1100
    To: "Greg 'groggy' Lehey" <grog@freebsd.org>
    
    

    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 <errno.h> into the appropriate gdb macro.

    -- 
    Peter Jeremy
    _______________________________________________
    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: Peter Pentchev: "Re: Header files with enums instead of defines?"