unused_variable.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file unused_variable.hpp
  9. * \author Andrey Semashev
  10. * \date 10.05.2008
  11. *
  12. * The header contains definition of a macro to suppress compiler warnings about unused variables.
  13. */
  14. #ifndef BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_
  15. #define BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_
  16. #include <boost/log/detail/config.hpp>
  17. #ifdef BOOST_HAS_PRAGMA_ONCE
  18. #pragma once
  19. #endif
  20. #if defined(__GNUC__)
  21. //! The macro suppresses compiler warnings for \c var being unused
  22. #define BOOST_LOG_UNUSED_VARIABLE(type, var, initializer) __attribute__((unused)) type var initializer
  23. #else
  24. namespace boost {
  25. BOOST_LOG_OPEN_NAMESPACE
  26. namespace aux {
  27. template< typename T >
  28. BOOST_FORCEINLINE void no_unused_warnings(T const&) BOOST_NOEXCEPT {}
  29. } // namespace aux
  30. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  31. } // namespace boost
  32. //! The macro suppresses compiler warnings for \c var being unused
  33. #define BOOST_LOG_UNUSED_VARIABLE(type, var, initializer) type var initializer; ::boost::log::aux::no_unused_warnings(var)
  34. #endif
  35. #endif // BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_