Skip to content

Commit 80f1f61

Browse files
committed
msvc
1 parent 90a10e1 commit 80f1f61

4 files changed

Lines changed: 25 additions & 36 deletions

File tree

examples/example.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,6 @@ get_current_thread_id()
5858
}
5959
#endif
6060

61-
#if defined(__GNUC__) || defined(__clang__)
62-
# define SUPPRESS_DEPRECATED \
63-
_Pragma("GCC diagnostic push"); \
64-
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
65-
# define RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
66-
#elif defined(_MSC_VER)
67-
# define SUPPRESS_DEPRECATED \
68-
__pragma(warning(push)); \
69-
__pragma(warning(disable : 4996))
70-
# define RESTORE_WARNINGS __pragma(warning(pop))
71-
#else
72-
# define SUPPRESS_DEPRECATED
73-
# define RESTORE_WARNINGS
74-
#endif
75-
7661
static double
7762
traces_sampler_callback(const sentry_transaction_context_t *transaction_ctx,
7863
sentry_value_t custom_sampling_ctx, const int *parent_sampled)
@@ -581,12 +566,12 @@ main(int argc, char **argv)
581566
SENTRY_LEVEL_INFO, "my-logger", "Hello user feedback!");
582567
sentry_uuid_t event_id = sentry_capture_event(event);
583568

584-
SUPPRESS_DEPRECATED
569+
SENTRY_SUPPRESS_DEPRECATED
585570
sentry_value_t user_feedback = sentry_value_new_user_feedback(
586571
&event_id, "some-name", "some-email", "some-comment");
587572

588573
sentry_capture_user_feedback(user_feedback);
589-
RESTORE_WARNINGS
574+
SENTRY_RESTORE_DEPRECATED
590575
}
591576

592577
if (has_arg(argc, argv, "capture-transaction")) {

include/sentry.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ extern "C" {
119119
# endif
120120
#endif
121121

122+
#if defined(__GNUC__) || defined(__clang__)
123+
# define SENTRY_SUPPRESS_DEPRECATED \
124+
_Pragma("GCC diagnostic push"); \
125+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
126+
# define SENTRY_RESTORE_DEPRECATED _Pragma("GCC diagnostic pop")
127+
#elif defined(_MSC_VER)
128+
# define SENTRY_SUPPRESS_DEPRECATED \
129+
__pragma(warning(push)); \
130+
__pragma(warning(disable : 4996))
131+
# define SENTRY_RESTORE_DEPRECATED __pragma(warning(pop))
132+
#else
133+
# define SENTRY_SUPPRESS_DEPRECATED
134+
# define SENTRY_RESTORE_DEPRECATED
135+
#endif
136+
122137
/* marks a function as experimental api */
123138
#ifndef SENTRY_EXPERIMENTAL_API
124139
# define SENTRY_EXPERIMENTAL_API SENTRY_API

src/sentry_value.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,9 +1350,11 @@ sentry_value_t
13501350
sentry_value_new_user_feedback(const sentry_uuid_t *uuid, const char *name,
13511351
const char *email, const char *comments)
13521352
{
1353+
SENTRY_SUPPRESS_DEPRECATED
13531354
return sentry_value_new_user_feedback_n(uuid, name,
13541355
sentry__guarded_strlen(name), email, sentry__guarded_strlen(email),
13551356
comments, sentry__guarded_strlen(comments));
1357+
SENTRY_RESTORE_DEPRECATED
13561358
}
13571359

13581360
sentry_value_t

tests/unit/sentry_testsupport.h

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,11 @@
9090
sentry_dsn_t *Varname = sentry__dsn_new(DSN_URL); \
9191
TEST_ASSERT(!!Varname)
9292

93-
#if defined(__GNUC__) || defined(__clang__)
94-
# define SENTRY_TEST_DEPRECATED(call) \
95-
do { \
96-
_Pragma("GCC diagnostic push"); \
97-
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\""); \
98-
call; \
99-
_Pragma("GCC diagnostic pop"); \
100-
} while (0)
101-
#elif defined(_MSC_VER)
102-
# define SENTRY_TEST_DEPRECATED(call) \
103-
do { \
104-
__pragma(warning(push)); \
105-
__pragma(warning(disable : 4996)); \
106-
call; \
107-
__pragma(warning(pop)); \
108-
} while (0)
109-
#else
110-
# define SENTRY_TEST_DEPRECATED(call) call
111-
#endif
93+
#define SENTRY_TEST_DEPRECATED(call) \
94+
do { \
95+
SENTRY_SUPPRESS_DEPRECATED \
96+
call; \
97+
SENTRY_RESTORE_DEPRECATED \
98+
} while (0)
11299

113100
#endif // SENTRY_TEST_SUPPORT_H_INCLUDED

0 commit comments

Comments
 (0)