c/5581: Feaure request for GNU extension to find number of elems in an enum
mark2776@yahoo.com
mark2776@yahoo.com
Mon Feb 4 11:06:00 GMT 2002
>Number: 5581
>Category: c
>Synopsis: Feaure request for GNU extension to find number of elems in an enum
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: support
>Submitter-Id: net
>Arrival-Date: Mon Feb 04 11:06:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: mark2776@yahoo.com
>Release: gcc-2.95.3
>Organization:
>Environment:
>Description:
I'd like to be able to get compile time information about the
size of an enum. For instance:
enum _enum_type {
ONE,
TWO
};
int t=numberof(_enum_type);
will make t=2
I fully understand that I have to use this information correctly
since there may be gaps in the enumeration but the fact that I
could shoot myself in the leg with this is not a reason not to
give this to me (with correct programming I could do good stuff
with this too...).
The same goes for unions.
Other possible attributes could be:
- lastof(enum_type) = the value of the last element.
- firstof(enum_type) = the value of the first element.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list