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 15 #ifndef BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_ 16 #define BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_ 17 18 #include <boost/log/detail/config.hpp> 19 20 #ifdef BOOST_HAS_PRAGMA_ONCE 21 #pragma once 22 #endif 23 24 #if defined(__GNUC__) 25 26 //! The macro suppresses compiler warnings for \c var being unused 27 #define BOOST_LOG_UNUSED_VARIABLE(type, var, initializer) __attribute__((unused)) type var initializer 28 29 #else 30 31 namespace boost { 32 33 BOOST_LOG_OPEN_NAMESPACE 34 35 namespace aux { 36 37 template< typename T > no_unused_warnings(T const &)38BOOST_FORCEINLINE void no_unused_warnings(T const&) BOOST_NOEXCEPT {} 39 40 } // namespace aux 41 42 BOOST_LOG_CLOSE_NAMESPACE // namespace log 43 44 } // namespace boost 45 46 //! The macro suppresses compiler warnings for \c var being unused 47 #define BOOST_LOG_UNUSED_VARIABLE(type, var, initializer) type var initializer; ::boost::log::aux::no_unused_warnings(var) 48 49 #endif 50 51 #endif // BOOST_LOG_UTILITY_UNUSED_VARIABLE_HPP_INCLUDED_ 52