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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // TODO(zhongwei.yao): WEBRTC_CPU_DETECTION is only used in one place; we should | 58 // TODO(zhongwei.yao): WEBRTC_CPU_DETECTION is only used in one place; we should |
59 // probably just remove it. | 59 // probably just remove it. |
60 #if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__)) | 60 #if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__)) |
61 #define WEBRTC_CPU_DETECTION | 61 #define WEBRTC_CPU_DETECTION |
62 #endif | 62 #endif |
63 | 63 |
64 #include <stdint.h> | 64 #include <stdint.h> |
65 | 65 |
66 // Annotate a function indicating the caller must examine the return value. | 66 // Annotate a function indicating the caller must examine the return value. |
67 // Use like: | 67 // Use like: |
68 // int foo() WARN_UNUSED_RESULT; | 68 // int foo() RTC_WARN_UNUSED_RESULT; |
69 // To explicitly ignore a result, see |ignore_result()| in <base/macros.h>. | 69 // To explicitly ignore a result, cast to void. |
70 // TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and | 70 // TODO(kwiberg): Remove when we can use [[nodiscard]] from C++17. |
71 // libjingle are merged. | 71 #if defined(__clang__) |
72 #if !defined(WARN_UNUSED_RESULT) | 72 #define RTC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) |
73 #if defined(__GNUC__) || defined(__clang__) | 73 #elif defined(__GNUC__) |
74 #define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) | 74 // gcc has a __warn_unused_result__ attribute, but you can't quiet it by |
| 75 // casting to void, so we don't use it. |
| 76 #define RTC_WARN_UNUSED_RESULT |
75 #else | 77 #else |
76 #define WARN_UNUSED_RESULT | 78 #define RTC_WARN_UNUSED_RESULT |
77 #endif | 79 #endif |
78 #endif // WARN_UNUSED_RESULT | |
79 | 80 |
80 // Put after a variable that might not be used, to prevent compiler warnings: | 81 // Put after a variable that might not be used, to prevent compiler warnings: |
81 // int result ATTRIBUTE_UNUSED = DoSomething(); | 82 // int result ATTRIBUTE_UNUSED = DoSomething(); |
82 // assert(result == 17); | 83 // assert(result == 17); |
83 // Deprecated since it only works with GCC & clang. See RTC_UNUSED below. | 84 // Deprecated since it only works with GCC & clang. See RTC_UNUSED below. |
84 // TODO(terelius): Remove. | 85 // TODO(terelius): Remove. |
85 #ifndef ATTRIBUTE_UNUSED | 86 #ifndef ATTRIBUTE_UNUSED |
86 #if defined(__GNUC__) || defined(__clang__) | 87 #if defined(__GNUC__) || defined(__clang__) |
87 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | 88 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) |
88 #else | 89 #else |
(...skipping 26 matching lines...) Expand all Loading... |
115 // int result = DoSomething(); | 116 // int result = DoSomething(); |
116 // assert(result == 17); | 117 // assert(result == 17); |
117 // RTC_UNUSED(result); | 118 // RTC_UNUSED(result); |
118 // Note: In most cases it is better to remove the unused variable rather than | 119 // Note: In most cases it is better to remove the unused variable rather than |
119 // suppressing the compiler warning. | 120 // suppressing the compiler warning. |
120 #ifndef RTC_UNUSED | 121 #ifndef RTC_UNUSED |
121 #define RTC_UNUSED(x) static_cast<void>(x) | 122 #define RTC_UNUSED(x) static_cast<void>(x) |
122 #endif // RTC_UNUSED | 123 #endif // RTC_UNUSED |
123 | 124 |
124 #endif // WEBRTC_TYPEDEFS_H_ | 125 #endif // WEBRTC_TYPEDEFS_H_ |
OLD | NEW |