Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Dec 2004 00:24:16 -0500 (EST)
From:      Sam <sah@softcardsystems.com>
To:        "Greg 'groggy' Lehey" <grog@freebsd.org>
Cc:        FreeBSD Architecture Mailing List <arch@freebsd.org>
Subject:   Re: Header files with enums instead of defines?
Message-ID:  <Pine.LNX.4.60.0412220018340.18646@athena>
In-Reply-To: <20041222020308.GX53357@wantadilla.lemis.com>
References:  <20041222010143.GS53357@wantadilla.lemis.com> <20041222020308.GX53357@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Tuesday, 21 December 2004 at 20:43:14 -0500, Brian Fundakowski Feldman wrote:
>> On Wed, Dec 22, 2004 at 11:31:43AM +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,
>>>
>>> To find out what that means, I need to go to
>>> /usr/src/include/sys/errno.h and look for 17.  I find:
>>>
>>> #define	EEXIST		17		/* File exists */
>>>
>>> If we were to change this to
>>>
>>> enum EEXIST = 17;	                /* File exists */
>>>
>>> I'd then be able to see:
>>>
>>>   xerrno = EEXIST,
>>>
>>> That makes debugging a whole lot easier.  About the only down side I
>>> can see is that you can't #undef an enum.  Is this a big deal?
>>
>> I think you'll screw up an awful lot of people that #ifdef based upon
>> the errno names.
>
> *sigh*  Yes, I didn't think about that.  Never mind.

Seems a shame to forgo utility to avoid breaking a fragile
assumption.  Maybe an ifdef ERRNO_T in errno.h that defines
an enum errno_t instead?

Sam



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