Re: Header files with enums instead of defines?

From: Greg 'groggy' Lehey (grog_at_FreeBSD.org)
Date: 12/23/04

  • Next message: Greg 'groggy' Lehey: "Re: Header files with enums instead of defines?"
    Date: Thu, 23 Dec 2004 09:40:12 +1030
    To: Peter Edwards <peadar.edwards@gmail.com>
    
    
    

    On Wednesday, 22 December 2004 at 13:00:50 +0000, Peter Edwards wrote:
    >> 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

    Yes, that's what I ended up doing (for some definition of "err_"). It
    still doesn't solve the more general issue of using enums instead of
    #defines, but I don't suppose we will solve that one any time soon.

    Greg

    --
    See complete headers for address and phone numbers.
    
    



  • Next message: Greg 'groggy' Lehey: "Re: Header files with enums instead of defines?"