diff options
author | Akira TAGOH <akira@tagoh.org> | 2015-11-25 18:44:30 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2015-11-25 18:44:30 +0900 |
commit | 7e0bae34211e835f0bd322764f5fa7534b3edfa4 (patch) | |
tree | 031849dd6123820ffd5727122dcb9c044784285e | |
parent | 6d381ceb2dced8ed7e6aaa8237df1f9db02b475d (diff) |
Add deprecation macros
-rw-r--r-- | liblangtag/lt-macros.h | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/liblangtag/lt-macros.h b/liblangtag/lt-macros.h index effbf43..83bbe31 100644 --- a/liblangtag/lt-macros.h +++ b/liblangtag/lt-macros.h @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * lt-macros.h - * Copyright (C) 2011-2012 Akira TAGOH + * Copyright (C) 2011-2015 Akira TAGOH * * Authors: * Akira TAGOH <akira@tagoh.org> @@ -186,6 +186,51 @@ # define LT_UNLIKELY(_e_) (_e_) #endif +/** + * LT_GNUC_DEPRECATED: + * + * Expands to the GNU C deprecated attribute if the compiler is gcc. + * It can be used to mark typedefs, variables and functions as deprecated. + * When called with the `-Wdeprecated-declarations` option. + * gcc will generate warnings when deprecated interfaces are used. + * + * Place the attribute after the declaration, just before the semicolon. + * + * See the GNU C documentation for more details. + */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#define LT_GNUC_DEPRECATED __attribute__((__deprecated__)) +#else +#define LT_GNUC_DEPRECATED +#endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#define LT_GNUC_DEPRECATED_FOR(f) __attribute__((deprecated("Use " #f " instead"))) +#else +#define LT_GNUC_DEPRECATED_FOR(f) LT_GNUC_DEPRECATED +#endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#define LT_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define LT_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic pop") +#elif defined (_MSC_VER) && (_MSC_VER >= 1500) +#define LT_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + __pragma (warning (push)) \ + __pragma (warning (disable : 4996)) +#define LT_GNUC_END_IGNORE_DEPRECATIONS \ + __pragma (warning (pop)) +#elif defined (__clang__) +#define LT_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define LT_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") +#else +#define LT_GNUC_BEGIN_IGNORE_DEPRECATIONS +#define LT_GNUC_END_IGNORE_DEPRECATIONS +#endif + /* boolean */ #ifndef FALSE # define FALSE (0) |