OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 #if defined(__GNUC__) || defined(__clang__) | 73 #if defined(__GNUC__) || defined(__clang__) |
74 #define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) | 74 #define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
75 #else | 75 #else |
76 #define WARN_UNUSED_RESULT | 76 #define WARN_UNUSED_RESULT |
77 #endif | 77 #endif |
78 #endif // WARN_UNUSED_RESULT | 78 #endif // WARN_UNUSED_RESULT |
79 | 79 |
80 // Put after a variable that might not be used, to prevent compiler warnings: | 80 // Put after a variable that might not be used, to prevent compiler warnings: |
81 // int result ATTRIBUTE_UNUSED = DoSomething(); | 81 // int result ATTRIBUTE_UNUSED = DoSomething(); |
82 // assert(result == 17); | 82 // assert(result == 17); |
83 // Deprecated since it only works with GCC & clang. See RTC_UNUSED below. | |
84 // TODO(terelius): Remove. | |
83 #ifndef ATTRIBUTE_UNUSED | 85 #ifndef ATTRIBUTE_UNUSED |
84 #if defined(__GNUC__) || defined(__clang__) | 86 #if defined(__GNUC__) || defined(__clang__) |
85 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | 87 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) |
86 #else | 88 #else |
87 #define ATTRIBUTE_UNUSED | 89 #define ATTRIBUTE_UNUSED |
88 #endif | 90 #endif |
89 #endif | 91 #endif |
90 | 92 |
91 // Macro to be used for switch-case fallthrough (required for enabling | 93 // Macro to be used for switch-case fallthrough (required for enabling |
92 // -Wimplicit-fallthrough warning on Clang). | 94 // -Wimplicit-fallthrough warning on Clang). |
93 #ifndef FALLTHROUGH | 95 #ifndef FALLTHROUGH |
94 #if defined(__clang__) | 96 #if defined(__clang__) |
95 #define FALLTHROUGH() [[clang::fallthrough]] | 97 #define FALLTHROUGH() [[clang::fallthrough]] |
96 #else | 98 #else |
97 #define FALLTHROUGH() do { } while (0) | 99 #define FALLTHROUGH() do { } while (0) |
98 #endif | 100 #endif |
99 #endif | 101 #endif |
100 | 102 |
101 #ifndef NO_RETURN | 103 #ifndef NO_RETURN |
102 // Annotate a function that will not return control flow to the caller. | 104 // Annotate a function that will not return control flow to the caller. |
103 #if defined(_MSC_VER) | 105 #if defined(_MSC_VER) |
104 #define NO_RETURN __declspec(noreturn) | 106 #define NO_RETURN __declspec(noreturn) |
105 #elif defined(__GNUC__) | 107 #elif defined(__GNUC__) |
106 #define NO_RETURN __attribute__ ((__noreturn__)) | 108 #define NO_RETURN __attribute__ ((__noreturn__)) |
107 #else | 109 #else |
108 #define NO_RETURN | 110 #define NO_RETURN |
109 #endif | 111 #endif |
110 #endif | 112 #endif |
111 | 113 |
114 // Prevent compiler from warning about an unused variable. | |
115 // int result = DoSomething(); | |
116 // assert(result == 17); | |
nisse-webrtc
2017/03/17 10:16:37
I think the example is misleading, we don't use as
terelius
2017/03/17 10:28:54
I based this on the example for ATTRIBUTE_UNUSED.
nisse-webrtc
2017/03/17 10:41:42
There's rarely a good reason to use RTC_UNUSED, so
terelius
2017/03/17 11:59:15
I like having an example that shows how to use the
| |
117 // RTC_UNUSED(result); | |
118 #ifndef RTC_UNUSED | |
119 #define RTC_UNUSED(x) RtcUnused(static_cast<const void*>(&x)) | |
nisse-webrtc
2017/03/17 10:16:37
Please try out this simpler definition:
#define
terelius
2017/03/17 10:28:54
Already tried. It does not work on Android bots.
nisse-webrtc
2017/03/17 10:41:42
Where's the failure? I see you tried
#define RTC
terelius
2017/03/17 11:59:15
Sorry, I misread your comment. Yeah, that seems to
| |
120 static inline void RtcUnused(const void* dummy) {} | |
121 #endif // RTC_UNUSED | |
122 | |
112 #endif // WEBRTC_TYPEDEFS_H_ | 123 #endif // WEBRTC_TYPEDEFS_H_ |
OLD | NEW |