Skip to content

Commit 7c4f66a

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
for tracepoint fallbacks, use c++-style mark-unused
Summary: Trying to mark macro params as unused using only the C preprocessor is painful. But we have an easier way in C++. Reviewed By: nslingerland Differential Revision: D60238723 fbshipit-source-id: c527bea47586e18dd40ecfa53cc60601771c8235
1 parent cab625c commit 7c4f66a

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

Diff for: folly/tracing/StaticTracepoint.h

+4-31
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,13 @@
4242

4343
#define FOLLY_HAVE_SDT 0
4444

45-
// Mark variadic macro args as unused from https://stackoverflow.com/a/31470425
46-
#define FOLLY_UNUSED0()
47-
#define FOLLY_UNUSED1(a) (void)(a)
48-
#define FOLLY_UNUSED2(a, b) (void)(a), FOLLY_UNUSED1(b)
49-
#define FOLLY_UNUSED3(a, b, c) (void)(a), FOLLY_UNUSED2(b, c)
50-
#define FOLLY_UNUSED4(a, b, c, d) (void)(a), FOLLY_UNUSED3(b, c, d)
51-
#define FOLLY_UNUSED5(a, b, c, d, e) (void)(a), FOLLY_UNUSED4(b, c, d, e)
52-
#define FOLLY_UNUSED6(a, b, c, d, e, f) (void)(a), FOLLY_UNUSED5(b, c, d, e, f)
53-
#define FOLLY_UNUSED7(a, b, c, d, e, f, g) \
54-
(void)(a), FOLLY_UNUSED6(b, c, d, e, f, g)
55-
#define FOLLY_UNUSED8(a, b, c, d, e, f, g, h) \
56-
(void)(a), FOLLY_UNUSED7(b, c, d, e, f, g, h)
57-
58-
#define FOLLY_VA_NUM_ARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
59-
#define FOLLY_VA_NUM_ARGS(...) \
60-
FOLLY_VA_NUM_ARGS_IMPL(100, ##__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0)
61-
62-
#define FOLLY_ALL_UNUSED_IMPL_(nargs) FOLLY_UNUSED##nargs
63-
#define FOLLY_ALL_UNUSED_IMPL(nargs) FOLLY_ALL_UNUSED_IMPL_(nargs)
64-
65-
#if defined(_MSC_VER)
66-
#define FOLLY_ALL_UNUSED(...)
67-
#else
68-
#define FOLLY_ALL_UNUSED(...) \
69-
FOLLY_ALL_UNUSED_IMPL(FOLLY_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
70-
#endif
71-
72-
#define FOLLY_SDT(provider, name, ...) \
73-
do { \
74-
FOLLY_ALL_UNUSED(__VA_ARGS__); \
45+
#define FOLLY_SDT(provider, name, ...) \
46+
do { \
47+
[](auto const&...) {}(__VA_ARGS__); \
7548
} while (0)
7649
#define FOLLY_SDT_WITH_SEMAPHORE(provider, name, ...) \
7750
do { \
78-
FOLLY_ALL_UNUSED(__VA_ARGS__); \
51+
[](auto const&...) {}(__VA_ARGS__); \
7952
} while (0)
8053
#define FOLLY_SDT_IS_ENABLED(provider, name) (false)
8154
#define FOLLY_SDT_SEMAPHORE(provider, name) \

0 commit comments

Comments
 (0)