Unused.h 929 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_unused_h
  6. #define mozilla_unused_h
  7. #include "mozilla/Types.h"
  8. #ifdef __cplusplus
  9. namespace mozilla {
  10. //
  11. // Suppress GCC warnings about unused return values with
  12. // Unused << SomeFuncDeclaredWarnUnusedReturnValue();
  13. //
  14. struct unused_t
  15. {
  16. template<typename T>
  17. inline void
  18. operator<<(const T& /*unused*/) const {}
  19. };
  20. extern MFBT_DATA const unused_t Unused;
  21. } // namespace mozilla
  22. #endif // __cplusplus
  23. // An alternative to mozilla::Unused for use in (a) C code and (b) code where
  24. // linking with unused.o is difficult.
  25. #define MOZ_UNUSED(expr) \
  26. do { if (expr) { (void)0; } } while (0)
  27. #endif // mozilla_unused_h