1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef RTC_BASE_SYSTEM_UNUSED_H_ 12 #define RTC_BASE_SYSTEM_UNUSED_H_ 13 14 // Annotate a function indicating the caller must examine the return value. 15 // Use like: 16 // int foo() RTC_WARN_UNUSED_RESULT; 17 // To explicitly ignore a result, cast to void. 18 // TODO(kwiberg): Remove when we can use [[nodiscard]] from C++17. 19 #if defined(__clang__) 20 #define RTC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 21 #elif defined(__GNUC__) 22 // gcc has a __warn_unused_result__ attribute, but you can't quiet it by 23 // casting to void, so we don't use it. 24 #define RTC_WARN_UNUSED_RESULT 25 #else 26 #define RTC_WARN_UNUSED_RESULT 27 #endif 28 29 // Prevent the compiler from warning about an unused variable. For example: 30 // int result = DoSomething(); 31 // assert(result == 17); 32 // RTC_UNUSED(result); 33 // Note: In most cases it is better to remove the unused variable rather than 34 // suppressing the compiler warning. 35 #ifndef RTC_UNUSED 36 #define RTC_UNUSED(x) static_cast<void>(x) 37 #endif // RTC_UNUSED 38 39 #endif // RTC_BASE_SYSTEM_UNUSED_H_ 40