The ODP_DEPRECATED macro uses the deprecated attribute which works only for types and functions, but not e.g. for fields of structure. So let's add ODP_DEPRECATED_FIELD macro suitable for fields, variables and enum values.
Also make ODP_DEPRECATED{,_FIELD} macros to be a no-op if ODP_ALLOW_DEPRECATED is defined. ODP code MUST be compiled with this macro, so that it supports deprecated API. Examples SHOULD be compiled without this macro defined, so that they show best current practice of using API but still MAY use the macro untill particular application is ported to new API. User applications SHOULD try to compile without ODP_ALLOW_DEPRECATED macro defined. Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> --- doc/helper-guide/Doxyfile | 1 + doc/platform-api-guide/Doxyfile | 1 + helper/Makefile.am | 1 + include/odp/api/spec/hints.h | 13 +++++++++++++ platform/linux-generic/Makefile.am | 1 + 5 files changed, 17 insertions(+) diff --git a/doc/helper-guide/Doxyfile b/doc/helper-guide/Doxyfile index bcc24539..62c1f862 100644 --- a/doc/helper-guide/Doxyfile +++ b/doc/helper-guide/Doxyfile @@ -40,6 +40,7 @@ PREDEFINED = __GNUC__ \ __LITTLE_ENDIAN_BITFIELD \ __x86_64__ \ ODP_PACKED \ + ODP_DEPRECATED_FIELD(x)=x \ "ODP_HANDLE_T(type)=odp_handle_t type" INTERNAL_DOCS = YES DOT_IMAGE_FORMAT = svg diff --git a/doc/platform-api-guide/Doxyfile b/doc/platform-api-guide/Doxyfile index fbe7c936..37175e09 100644 --- a/doc/platform-api-guide/Doxyfile +++ b/doc/platform-api-guide/Doxyfile @@ -17,4 +17,5 @@ PREDEFINED = __GNUC__ \ __LITTLE_ENDIAN_BITFIELD \ __x86_64__ \ ODP_PACKED \ + ODP_DEPRECATED_FIELD(x)=x \ "ODP_HANDLE_T(type)=odp_handle_t type" diff --git a/helper/Makefile.am b/helper/Makefile.am index 2c5452dc..3bd38a46 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -10,6 +10,7 @@ AM_CFLAGS += -I$(top_srcdir)/include AM_CFLAGS += -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@ AM_CFLAGS += -I$(top_builddir)/platform/@with_platform@/include AM_CFLAGS += -I$(top_builddir)/include +AM_CFLAGS += -DODP_ALLOW_DEPRECATED AM_LDFLAGS += -version-number '$(ODPHELPER_LIBSO_VERSION)' diff --git a/include/odp/api/spec/hints.h b/include/odp/api/spec/hints.h index 82400f07..3b70db6f 100644 --- a/include/odp/api/spec/hints.h +++ b/include/odp/api/spec/hints.h @@ -54,7 +54,20 @@ extern "C" { /** * Indicate deprecated variables, functions or types */ +#ifdef ODP_ALLOW_DEPRECATED #define ODP_DEPRECATED __attribute__((__deprecated__)) +#else +#define ODP_DEPRECATED +#endif + +/** + * Indicate deprecated field, bitfield or enum value + */ +#ifndef ODP_ALLOW_DEPRECATED +#define ODP_DEPRECATED_FIELD(x) __odp_deprecated_ ## x +#else +#define ODP_DEPRECATED_FIELD(x) x +#endif /** * Intentionally unused variables of functions diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index b21df449..800bf5e8 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -10,6 +10,7 @@ AM_CFLAGS += -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@ AM_CFLAGS += -I$(top_builddir)/include AM_CFLAGS += -Iinclude AM_CFLAGS += -DSYSCONFDIR=\"@sysconfdir@\" +AM_CFLAGS += -DODP_ALLOW_DEPRECATED include_HEADERS = \ $(top_srcdir)/include/odp.h \ -- 2.11.0