Header files with enums instead of defines?

Greg 'groggy' Lehey grog at FreeBSD.org
Tue Dec 21 17:01:47 PST 2004


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?

Greg
--
See complete headers for address and phone numbers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20041222/19dbffb6/attachment.bin


More information about the freebsd-arch mailing list