Header files with enums instead of defines?

Greg 'groggy' Lehey grog at FreeBSD.org
Wed Dec 22 15:10:25 PST 2004


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 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/20041223/abbcbd9e/attachment.bin


More information about the freebsd-arch mailing list