diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-13 17:02:59 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-09-13 22:12:42 -0700 |
commit | 4f0f3f85cdab90635bbf58e17bc1dc91fc7f06af (patch) | |
tree | 05ca029ac53de45270d886c3e66803beeb91a60a | |
parent | 7626a0784b602ea01192a068c745a21bd9095781 (diff) |
api: don't use intermediate variables for deprecation warnings
Using an intermediate constant variable breaks compilation with C
compilers, as these variables cannot be used as initializers.
Instead, define a deprecated type and cast all deprecated symbols to
that type. We lose the information about what the new replacement
symbol is, but we don't break compilation.
Also, add MBIM_DISABLE_DEPRECATED guards around deprecated symbols. So
that when this symbol is defined, e.g. via CFLAGS, building a program
that uses the libmbim API will fail if the program references
deprecated symbols. For now we just use it to keep gtk-doc-scan happy
and avoid unnecessary warnings.
Equivalent to ModemManager commits eedd4ab4457 and f0bb6ef856.
-rw-r--r-- | docs/reference/libmbim-glib/Makefile.am | 2 | ||||
-rw-r--r-- | docs/reference/libmbim-glib/libmbim-glib-common.sections | 3 | ||||
-rw-r--r-- | src/libmbim-glib/mbim-compat.c | 4 | ||||
-rw-r--r-- | src/libmbim-glib/mbim-compat.h | 22 |
4 files changed, 22 insertions, 9 deletions
diff --git a/docs/reference/libmbim-glib/Makefile.am b/docs/reference/libmbim-glib/Makefile.am index 0e219ca..94d7c7b 100644 --- a/docs/reference/libmbim-glib/Makefile.am +++ b/docs/reference/libmbim-glib/Makefile.am @@ -29,7 +29,7 @@ $(DOC_MODULE)-sections.mstamp: $(ALL_SECTIONS) BUILT_SOURCES = $(DOC_MODULE)-sections.mstamp # Extra options to supply to gtkdoc-scan -SCAN_OPTIONS = --rebuild-types +SCAN_OPTIONS = --rebuild-types --deprecated-guards="MBIM_DISABLE_DEPRECATED" # The directory containing the source code. DOC_SOURCE_DIR = \ diff --git a/docs/reference/libmbim-glib/libmbim-glib-common.sections b/docs/reference/libmbim-glib/libmbim-glib-common.sections index a4c3120..ac7c02c 100644 --- a/docs/reference/libmbim-glib/libmbim-glib-common.sections +++ b/docs/reference/libmbim-glib/libmbim-glib-common.sections @@ -561,4 +561,7 @@ MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH mbim_message_device_service_subscriber_list_response_parse mbim_message_device_service_subscriber_list_set_new +<SUBSECTION Private> +MbimDeprecatedCidBasicConnect +MbimDeprecatedRegistrationFlag </SECTION> diff --git a/src/libmbim-glib/mbim-compat.c b/src/libmbim-glib/mbim-compat.c index edf513d..b69a53d 100644 --- a/src/libmbim-glib/mbim-compat.c +++ b/src/libmbim-glib/mbim-compat.c @@ -28,6 +28,8 @@ * This section defines types and functions that have been deprecated. */ +#ifndef MBIM_DISABLE_DEPRECATED + /*****************************************************************************/ /* 'Service Subscriber List' rename to 'Service Subscribe List' */ @@ -81,3 +83,5 @@ mbim_message_device_service_subscriber_list_response_parse ( events, error)); } + +#endif /* MBIM_DISABLE_DEPRECATED */ diff --git a/src/libmbim-glib/mbim-compat.h b/src/libmbim-glib/mbim-compat.h index ca5c3cf..3a16da3 100644 --- a/src/libmbim-glib/mbim-compat.h +++ b/src/libmbim-glib/mbim-compat.h @@ -32,9 +32,15 @@ G_BEGIN_DECLS +#ifndef MBIM_DISABLE_DEPRECATED + /*****************************************************************************/ /* Registration flags name fixup */ +/* The following type exists just so that we can get deprecation warnings */ +G_DEPRECATED +typedef int MbimDeprecatedRegistrationFlag; + /** * MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH: * @@ -42,14 +48,15 @@ G_BEGIN_DECLS * * Deprecated:1.8.0: Use MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH instead. */ -G_DEPRECATED_FOR (MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH) -static const int MBIM_DEPRECATED_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH = - MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH; -#define MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH MBIM_DEPRECATED_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH +#define MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH (MbimDeprecatedRegistrationFlag) MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH /*****************************************************************************/ /* 'Service Subscriber List' rename to 'Service Subscribe List' */ +/* The following type exists just so that we can get deprecation warnings */ +G_DEPRECATED +typedef int MbimDeprecatedCidBasicConnect; + /** * MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST: * @@ -57,10 +64,7 @@ static const int MBIM_DEPRECATED_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMAT * * Deprecated:1.8.0: Use MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST instead. */ -G_DEPRECATED_FOR (MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST) -static const int MBIM_DEPRECATED_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST = - MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST; -#define MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST MBIM_DEPRECATED_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST +#define MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST (MbimDeprecatedCidBasicConnect) MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST G_DEPRECATED_FOR (mbim_message_device_service_subscribe_list_set_new) MbimMessage *mbim_message_device_service_subscriber_list_set_new ( @@ -75,6 +79,8 @@ gboolean mbim_message_device_service_subscriber_list_response_parse ( MbimEventEntry ***events, GError **error); +#endif /* MBIM_DISABLE_DEPRECATED */ + G_END_DECLS #endif /* _LIBMBIM_GLIB_MBIM_COMPAT_H_ */ |