Bug 1202965 (part 1) - Add MOZ_UNUSED. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 09 Sep 2015 17:01:28 -0700
changeset 294290 4805fa9a89fe1165829e60140f3050ff09c2d656
parent 294268 c75f9ca74a29c05a3457d33531548c63f9b6d784
child 294291 7a715b603ac0ab04990ac464d5a78551b3c513ee
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1202965
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202965 (part 1) - Add MOZ_UNUSED. r=froydnj.
mfbt/unused.h
--- a/mfbt/unused.h
+++ b/mfbt/unused.h
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_unused_h
 #define mozilla_unused_h
 
 #include "mozilla/Types.h"
 
+#ifdef __cplusplus
+
 namespace mozilla {
 
 //
 // Suppress GCC warnings about unused return values with
 //   unused << SomeFuncDeclaredWarnUnusedReturnValue();
 //
 struct unused_t
 {
@@ -24,9 +26,16 @@ extern MFBT_DATA const unused_t unused;
 template<typename T>
 inline void
 operator<<(const unused_t& /*unused*/, const T& /*unused*/)
 {
 }
 
 } // namespace mozilla
 
+#endif // __cplusplus
+
+// An alternative to mozilla::unused for use in (a) C code and (b) code where
+// linking with unused.o is difficult.
+#define MOZ_UNUSED(expr) \
+  do { if (expr) { (void)0; } } while (0)
+
 #endif // mozilla_unused_h