[Bug c/45168] New: There should be a way to mark specific enum members as deprecated

joseph dot h dot garvin at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 2 21:33:00 GMT 2010


It's fairly common in C and C++ libraries to have an enum with each element
representing an aspect of a request. In these situations it would be nice to be
able to deprecate specific enum members. For example the user wants to retrieve
a Foo from a server, and Foo's have 3 parts, they might make a request using an
API like this:

enum FooRequest {
    WANT_FIZZ = 1 << 0,
    WANT_BUZZ = 1 << 1,
    WANT_BEEZLE = 1 << 2
};

make_request(WANT_FIZZ | WANT_BUZZ, callback);

And perhaps WANT_BUZZ should be deprecated because now Foo's have some other,
better thing to request instead that should be transitioned to. It'd be nice to
write:

enum FooRequest {
    WANT_FIZZ = 1 << 0,
    WANT_BUZZ = 1 << 1 __attribute__((deprecated)),
    WANT_BEEZLE = 1 << 2,
    WANT_SUPERIOR_BUZZ = 1 << 3
};

So that at compile time users would be notified that WANT_BUZZ is no longer the
way to go.


-- 
           Summary: There should be a way to mark specific enum members as
                    deprecated
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joseph dot h dot garvin at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45168



More information about the Gcc-bugs mailing list