Add ALLOW_UNUSED and update COMPILE_ASSERT to Chromium's latest.
Fixes building with gcc 4.8. TBR=fdegans@google.com BUG=chromium:321833 Review URL: https://webrtc-codereview.appspot.com/12439004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6050 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// Borrowed from Chromium's src/base/basictypes.h.
|
||||
// Borrowed from Chromium's src/base/macros.h.
|
||||
|
||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
||||
@ -31,13 +31,20 @@
|
||||
// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
|
||||
// libjingle are merged.
|
||||
#if !defined(COMPILE_ASSERT)
|
||||
#if __cplusplus >= 201103L
|
||||
// Under C++11, just use static_assert.
|
||||
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
|
||||
|
||||
#else
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
|
||||
#define COMPILE_ASSERT(expr, msg) \
|
||||
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||
#endif // COMPILE_ASSERT
|
||||
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] ALLOW_UNUSED
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
#endif // !defined(COMPILE_ASSERT)
|
||||
|
||||
// Implementation details of COMPILE_ASSERT:
|
||||
//
|
||||
|
@ -96,6 +96,17 @@ typedef unsigned __int64 uint64_t;
|
||||
#define OVERRIDE
|
||||
#endif
|
||||
|
||||
// Annotate a variable indicating it's ok if the variable is not used.
|
||||
// (Typically used to silence a compiler warning when the assignment
|
||||
// is important for some other reason.)
|
||||
// Use like:
|
||||
// int x ALLOW_UNUSED = ...;
|
||||
#if defined(__GNUC__)
|
||||
#define ALLOW_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define ALLOW_UNUSED
|
||||
#endif
|
||||
|
||||
// Annotate a function indicating the caller must examine the return value.
|
||||
// Use like:
|
||||
// int foo() WARN_UNUSED_RESULT;
|
||||
|
Reference in New Issue
Block a user