Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 1996 21:18:59 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        amcrae@cisco.com, hackers@FreeBSD.org, phk@FreeBSD.org
Subject:   Re: enum considered bad ?
Message-ID:  <199610171118.VAA25414@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I use enums where I can, and they are encouraged here at cisco.
>I prefer them because the compiler can be a little stricter
>with type checking and switch warnings etc., but it is
>surprising how many times you want to store those numbers
>in a char (so you can't declare the variable as an enum) or
>get at them in an assembler routiner.

gcc's __attribute__(()) works right in some cases, but not here:

	enum foo { ONE, TWO } __attribute__((__mode__(__QI__)));

tells you that __attribute__(()) doesn't apply to types.

	enum foo xxx __attribute__((__mode__(__QI__)));

gives an ordinary enum.

	enum foo xxx __attribute__((__mode__(__DI__)));

gives a long long enum.

I often store enums in char variables and interpret the
char variables in debuggers by casting back to enums.

Bruce



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