Skip to content

Instantly share code, notes, and snippets.

@rotu
Last active May 11, 2020 22:11
Show Gist options
  • Save rotu/d65b382ef424e97df93d68e7f73d5c0c to your computer and use it in GitHub Desktop.
Save rotu/d65b382ef424e97df93d68e7f73d5c0c to your computer and use it in GitHub Desktop.
enum Foo1 {
Bar1=1,
Baz1
#ifdef _MSC_VER
#pragma deprecated(Baz1)
#else
__attribute__ ((deprecated("Use something else")))
#endif
= 2,
Bang1=3,
};
#ifdef _MSC_VER
#define DECLARE_DEPRECATED(name, msg) name __pragma(deprecated(name))
#else
#define DECLARE_DEPRECATED(name, msg) name __attribute__((deprecated(msg)))
#endif
enum Foo2 {
Bar2=1,
DECLARE_DEPRECATED(Baz2, "Use something else") = 2,
Bang2=3,
};
int main(){
enum Foo1 bar1 = Bar1;
enum Foo1 baz1 = Baz1;
enum Foo2 bar2 = Bar2;
enum Foo2 baz2 = Baz2;
}
@rotu
Copy link
Author

rotu commented May 11, 2020

tested to work in gcc, clang, and visual studio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment