Skip to content

Commit c55b3d7

Browse files
committed
meta: add SENTRY_DEPRECATED(msg) macro
1 parent 0922029 commit c55b3d7

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

include/sentry.h

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ extern "C" {
100100
# endif
101101
#endif
102102

103+
#if defined(__has_attribute)
104+
# if __has_attribute(deprecated)
105+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
106+
# else
107+
# define SENTRY_DEPRECATED(msg)
108+
# endif
109+
#elif defined(__GNUC__)
110+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
111+
#elif defined(__clang__)
112+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
113+
#elif defined(_MSC_VER)
114+
# define SENTRY_DEPRECATED(msg) __declspec(deprecated(msg))
115+
#else
116+
# define SENTRY_DEPRECATED(msg)
117+
#endif
118+
103119
/* marks a function as experimental api */
104120
#ifndef SENTRY_EXPERIMENTAL_API
105121
# define SENTRY_EXPERIMENTAL_API SENTRY_API
@@ -515,13 +531,13 @@ SENTRY_EXPERIMENTAL_API char *sentry_value_to_msgpack(
515531
* Adds a stack trace to an event.
516532
*
517533
* The stack trace is added as part of a new thread object.
518-
* This function is **deprecated** in favor of using
519-
* `sentry_value_new_stacktrace` in combination with `sentry_value_new_thread`
520-
* and `sentry_event_add_thread`.
521534
*
522535
* If `ips` is NULL the current stack trace is captured, otherwise `len`
523536
* stack trace instruction pointers are attached to the event.
524537
*/
538+
SENTRY_DEPRECATED(
539+
"Use `sentry_value_new_stacktrace` in combination with "
540+
"`sentry_value_new_thread` and `sentry_event_add_thread` instead")
525541
SENTRY_EXPERIMENTAL_API void sentry_event_value_add_stacktrace(
526542
sentry_value_t event, void **ips, size_t len);
527543

@@ -772,11 +788,8 @@ SENTRY_API void sentry_transport_free(sentry_transport_t *transport);
772788
* It is a convenience function which works with a borrowed `data`, and will
773789
* automatically free the envelope, so the user provided function does not need
774790
* to do that.
775-
*
776-
* This function is *deprecated* and will be removed in a future version.
777-
* It is here for backwards compatibility. Users should migrate to the
778-
* `sentry_transport_new` API.
779791
*/
792+
SENTRY_DEPRECATED("Use `sentry_transport_new` instead")
780793
SENTRY_API sentry_transport_t *sentry_new_function_transport(
781794
void (*func)(const sentry_envelope_t *envelope, void *data), void *data);
782795

@@ -1053,13 +1066,13 @@ SENTRY_API const char *sentry_options_get_proxy(const sentry_options_t *opts);
10531066
/**
10541067
* Configures the proxy.
10551068
*
1056-
* This is a **deprecated** alias for `sentry_options_set_proxy(_n)`.
1057-
*
10581069
* The given proxy has to include the full scheme,
10591070
* eg. `http://some.proxy/.
10601071
*/
1072+
SENTRY_DEPRECATED("Use `sentry_options_set_proxy` instead")
10611073
SENTRY_API void sentry_options_set_http_proxy(
10621074
sentry_options_t *opts, const char *proxy);
1075+
SENTRY_DEPRECATED("Use `sentry_options_set_proxy_n` instead")
10631076
SENTRY_API void sentry_options_set_http_proxy_n(
10641077
sentry_options_t *opts, const char *proxy, size_t proxy_len);
10651078

@@ -1465,10 +1478,9 @@ SENTRY_API int sentry_close(void);
14651478
/**
14661479
* Shuts down the sentry client and forces transports to flush out.
14671480
*
1468-
* This is a **deprecated** alias for `sentry_close`.
1469-
*
14701481
* Returns 0 on success.
14711482
*/
1483+
SENTRY_DEPRECATED("Use `sentry_close` instead")
14721484
SENTRY_API int sentry_shutdown(void);
14731485

14741486
/**
@@ -2573,14 +2585,14 @@ SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version(void);
25732585

25742586
/**
25752587
* Sentry SDK name set during build time.
2576-
* Deprecated: Please use sentry_options_get_sdk_name instead.
25772588
*/
2589+
SENTRY_DEPRECATED("Use `sentry_options_get_sdk_name` instead")
25782590
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name(void);
25792591

25802592
/**
25812593
* Sentry SDK User-Agent set during build time.
2582-
* Deprecated: Please use sentry_options_get_user_agent instead.
25832594
*/
2595+
SENTRY_DEPRECATED("Use `sentry_options_get_user_agent` instead")
25842596
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent(void);
25852597

25862598
#ifdef __cplusplus

0 commit comments

Comments
 (0)