Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file config.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 08.03.2007 Chris@16: * Chris@16: * \brief This header is the Boost.Log library implementation, see the library documentation Chris@16: * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file Chris@16: * internal configuration macros are defined. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_ Chris@16: Chris@16: // This check must be before any system headers are included, or __MSVCRT_VERSION__ may get defined to 0x0600 Chris@16: #if defined(__MINGW32__) && !defined(__MSVCRT_VERSION__) Chris@16: // Target MinGW headers to at least MSVC 7.0 runtime by default. This will enable some useful functions. Chris@16: #define __MSVCRT_VERSION__ 0x0700 Chris@16: #endif Chris@16: Chris@16: #include // To bring in libc macros Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_NO_RTTI) Chris@16: # error Boost.Log: RTTI is required by the library Chris@16: #endif Chris@16: Chris@101: #if defined(_MSC_VER) && _MSC_VER >= 1600 Chris@101: # define BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH Chris@101: #endif Chris@101: Chris@101: #if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH) Chris@101: #include Chris@101: #endif Chris@101: Chris@16: #if !defined(BOOST_WINDOWS) Chris@16: # ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT Chris@16: # define BOOST_LOG_WITHOUT_DEBUG_OUTPUT Chris@16: # endif Chris@16: # ifndef BOOST_LOG_WITHOUT_EVENT_LOG Chris@16: # define BOOST_LOG_WITHOUT_EVENT_LOG Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #if defined(BOOST_MSVC) Chris@16: // For some reason MSVC 9.0 fails to link the library if static integral constants are defined in cpp Chris@16: # define BOOST_LOG_BROKEN_STATIC_CONSTANTS_LINKAGE Chris@16: # if _MSC_VER <= 1310 Chris@16: // MSVC 7.1 sometimes fails to match out-of-class template function definitions with Chris@16: // their declarations if the return type or arguments of the functions involve typename keyword Chris@16: // and depend on the template parameters. Chris@16: # define BOOST_LOG_BROKEN_TEMPLATE_DEFINITION_MATCHING Chris@16: # endif Chris@16: # if _MSC_VER <= 1400 Chris@16: // Older MSVC versions reject friend declarations for class template specializations Chris@16: # define BOOST_LOG_BROKEN_FRIEND_TEMPLATE_SPECIALIZATIONS Chris@16: # endif Chris@16: # if _MSC_VER <= 1600 Chris@16: // MSVC up to 10.0 attempts to invoke copy constructor when initializing a const reference from rvalue returned from a function. Chris@16: // This fails when the returned value cannot be copied (only moved): Chris@16: // Chris@16: // class base {}; Chris@16: // class derived : public base { BOOST_MOVABLE_BUT_NOT_COPYABLE(derived) }; Chris@16: // derived foo(); Chris@16: // base const& var = foo(); // attempts to call copy constructor of derived Chris@16: # define BOOST_LOG_BROKEN_REFERENCE_FROM_RVALUE_INIT Chris@16: # endif Chris@16: # if !defined(_STLPORT_VERSION) Chris@16: // MSVC 9.0 mandates packaging of STL classes, which apparently affects alignment and Chris@16: // makes alignment_of< T >::value no longer be a power of 2 for types that derive from STL classes. Chris@16: // This breaks type_with_alignment and everything that relies on it. Chris@16: // This doesn't happen with non-native STLs, such as STLPort. Strangely, this doesn't show with Chris@16: // STL classes themselves or most of the user-defined derived classes. Chris@16: // Not sure if that happens with other MSVC versions. Chris@16: // See: http://svn.boost.org/trac/boost/ticket/1946 Chris@16: # define BOOST_LOG_BROKEN_STL_ALIGNMENT Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: #if defined(BOOST_INTEL) || defined(__SUNPRO_CC) Chris@16: // Intel compiler and Sun Studio 12.3 have problems with friend declarations for nested class templates Chris@16: # define BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS Chris@16: #endif Chris@16: Chris@16: #if defined(BOOST_MSVC) && BOOST_MSVC <= 1600 Chris@16: // MSVC cannot interpret constant expressions in certain contexts, such as non-type template parameters Chris@16: # define BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS Chris@16: #endif Chris@16: Chris@16: #if defined(__CYGWIN__) Chris@16: // Boost.ASIO is broken on Cygwin Chris@16: # define BOOST_LOG_NO_ASIO Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_LOG_USE_NATIVE_SYSLOG) && defined(BOOST_LOG_NO_ASIO) Chris@16: # ifndef BOOST_LOG_WITHOUT_SYSLOG Chris@16: # define BOOST_LOG_WITHOUT_SYSLOG Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: #if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 2) Chris@16: // GCC 4.1 and 4.2 have buggy anonymous namespaces support, which interferes with symbol linkage Chris@16: # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace anonymous {} using namespace anonymous; namespace anonymous Chris@16: #else Chris@16: # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace Chris@16: #endif Chris@16: Chris@16: #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || (defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 6)) Chris@16: // GCC up to 4.6 (inclusively) did not support expanding template argument packs into non-variadic template arguments Chris@16: #define BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION Chris@16: #endif Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: # define BOOST_LOG_NO_VTABLE __declspec(novtable) Chris@16: #elif defined(__GNUC__) Chris@16: # define BOOST_LOG_NO_VTABLE Chris@16: #else Chris@16: # define BOOST_LOG_NO_VTABLE Chris@16: #endif Chris@16: Chris@16: // An MS-like compilers' extension that allows to optimize away the needless code Chris@16: #if defined(_MSC_VER) Chris@16: # define BOOST_LOG_ASSUME(expr) __assume(expr) Chris@16: #else Chris@16: # define BOOST_LOG_ASSUME(expr) Chris@16: #endif Chris@16: Chris@16: // The statement marking unreachable branches of code to avoid warnings Chris@16: #if defined(BOOST_CLANG) Chris@16: # if __has_builtin(__builtin_unreachable) Chris@16: # define BOOST_LOG_UNREACHABLE() __builtin_unreachable() Chris@16: # endif Chris@16: #elif defined(__GNUC__) Chris@16: # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) Chris@16: # define BOOST_LOG_UNREACHABLE() __builtin_unreachable() Chris@16: # endif Chris@16: #elif defined(_MSC_VER) Chris@16: # define BOOST_LOG_UNREACHABLE() __assume(0) Chris@16: #endif Chris@16: #if !defined(BOOST_LOG_UNREACHABLE) Chris@16: # define BOOST_LOG_UNREACHABLE() Chris@101: # define BOOST_LOG_UNREACHABLE_RETURN(r) return r Chris@101: #else Chris@101: # define BOOST_LOG_UNREACHABLE_RETURN(r) BOOST_LOG_UNREACHABLE() Chris@16: #endif Chris@16: Chris@16: // Some compilers support a special attribute that shows that a function won't return Chris@16: #if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) Chris@16: // GCC and Sun Studio 12 support attribute syntax Chris@16: # define BOOST_LOG_NORETURN __attribute__((noreturn)) Chris@16: #elif defined (_MSC_VER) Chris@16: // Microsoft-compatible compilers go here Chris@16: # define BOOST_LOG_NORETURN __declspec(noreturn) Chris@16: #else Chris@16: // The rest compilers might emit bogus warnings about missing return statements Chris@16: // in functions with non-void return types when throw_exception is used. Chris@16: # define BOOST_LOG_NORETURN Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_LOG_BUILDING_THE_LIB) Chris@16: Chris@16: // Detect if we're dealing with dll Chris@16: # if defined(BOOST_LOG_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) Chris@16: # define BOOST_LOG_DLL Chris@16: # endif Chris@16: Chris@16: # if defined(BOOST_LOG_DLL) Chris@16: # if defined(BOOST_SYMBOL_IMPORT) Chris@16: # define BOOST_LOG_API BOOST_SYMBOL_IMPORT Chris@16: # elif defined(BOOST_HAS_DECLSPEC) Chris@16: # define BOOST_LOG_API __declspec(dllimport) Chris@16: # endif Chris@16: # endif Chris@16: # ifndef BOOST_LOG_API Chris@16: # define BOOST_LOG_API Chris@16: # endif Chris@16: // Chris@16: // Automatically link to the correct build variant where possible. Chris@16: // Chris@16: # if !defined(BOOST_ALL_NO_LIB) Chris@16: # if !defined(BOOST_LOG_NO_LIB) Chris@16: # define BOOST_LIB_NAME boost_log Chris@16: # if defined(BOOST_LOG_DLL) Chris@16: # define BOOST_DYN_LINK Chris@16: # endif Chris@16: # include Chris@16: # endif Chris@16: // In static-library builds compilers ignore auto-link comments from Boost.Log binary to Chris@16: // other Boost libraries. We explicitly add comments here for other libraries. Chris@16: // In dynamic-library builds this is not needed. Chris@16: # if !defined(BOOST_LOG_DLL) Chris@16: # include Chris@16: # include Chris@16: # if !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE) Chris@16: # define BOOST_LIB_NAME boost_date_time Chris@16: # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK) Chris@16: # define BOOST_DYN_LINK Chris@16: # endif Chris@16: # include Chris@16: # endif Chris@16: // Boost.Thread's config is included below, if needed Chris@16: # endif Chris@16: # endif // auto-linking disabled Chris@16: Chris@16: #else // !defined(BOOST_LOG_BUILDING_THE_LIB) Chris@16: Chris@16: # if defined(BOOST_LOG_DLL) Chris@16: # if defined(BOOST_SYMBOL_EXPORT) Chris@16: # define BOOST_LOG_API BOOST_SYMBOL_EXPORT Chris@16: # elif defined(BOOST_HAS_DECLSPEC) Chris@16: # define BOOST_LOG_API __declspec(dllexport) Chris@16: # endif Chris@16: # endif Chris@16: # ifndef BOOST_LOG_API Chris@16: # define BOOST_LOG_API BOOST_SYMBOL_VISIBLE Chris@16: # endif Chris@16: Chris@16: #endif // !defined(BOOST_LOG_BUILDING_THE_LIB) Chris@16: Chris@16: // By default we provide support for both char and wchar_t Chris@16: #if !defined(BOOST_LOG_WITHOUT_CHAR) Chris@16: # define BOOST_LOG_USE_CHAR Chris@16: #endif Chris@16: #if !defined(BOOST_LOG_WITHOUT_WCHAR_T) Chris@16: # define BOOST_LOG_USE_WCHAR_T Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: // Check if multithreading is supported Chris@16: # if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS) Chris@16: # define BOOST_LOG_NO_THREADS Chris@16: # endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS) Chris@16: #endif // !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: Chris@16: #if !defined(BOOST_LOG_NO_THREADS) Chris@16: // We need this header to (i) enable auto-linking with Boost.Thread and Chris@16: // (ii) to bring in configuration macros of Boost.Thread. Chris@16: # include Chris@16: #endif // !defined(BOOST_LOG_NO_THREADS) Chris@16: Chris@16: #if !defined(BOOST_LOG_NO_THREADS) Chris@16: # define BOOST_LOG_EXPR_IF_MT(expr) expr Chris@16: #else Chris@16: # undef BOOST_LOG_USE_COMPILER_TLS Chris@16: # define BOOST_LOG_EXPR_IF_MT(expr) Chris@16: #endif // !defined(BOOST_LOG_NO_THREADS) Chris@16: Chris@16: #if defined(BOOST_LOG_USE_COMPILER_TLS) Chris@16: # if defined(__GNUC__) || defined(__SUNPRO_CC) Chris@16: # define BOOST_LOG_TLS __thread Chris@16: # elif defined(BOOST_MSVC) Chris@16: # define BOOST_LOG_TLS __declspec(thread) Chris@16: # else Chris@16: # undef BOOST_LOG_USE_COMPILER_TLS Chris@16: # endif Chris@16: #endif // defined(BOOST_LOG_USE_COMPILER_TLS) Chris@16: Chris@101: #ifndef BOOST_LOG_CPU_CACHE_LINE_SIZE Chris@101: //! The macro defines the CPU cache line size for the target architecture. This is mostly used for optimization. Chris@101: #define BOOST_LOG_CPU_CACHE_LINE_SIZE 64 Chris@101: #endif Chris@101: Chris@16: namespace boost { Chris@16: Chris@16: // Setup namespace name Chris@16: #if !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: # if defined(BOOST_LOG_DLL) Chris@16: # if defined(BOOST_LOG_NO_THREADS) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2_st Chris@16: # else Chris@16: # if defined(BOOST_THREAD_PLATFORM_PTHREAD) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix Chris@16: # elif defined(BOOST_THREAD_PLATFORM_WIN32) Chris@16: # if defined(BOOST_LOG_USE_WINNT6_API) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6 Chris@16: # else Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5 Chris@16: # endif // defined(BOOST_LOG_USE_WINNT6_API) Chris@16: # else Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2_mt Chris@16: # endif Chris@16: # endif // defined(BOOST_LOG_NO_THREADS) Chris@16: # else Chris@16: # if defined(BOOST_LOG_NO_THREADS) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2s_st Chris@16: # else Chris@16: # if defined(BOOST_THREAD_PLATFORM_PTHREAD) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix Chris@16: # elif defined(BOOST_THREAD_PLATFORM_WIN32) Chris@16: # if defined(BOOST_LOG_USE_WINNT6_API) Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6 Chris@16: # else Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5 Chris@16: # endif // defined(BOOST_LOG_USE_WINNT6_API) Chris@16: # else Chris@16: # define BOOST_LOG_VERSION_NAMESPACE v2s_mt Chris@16: # endif Chris@16: # endif // defined(BOOST_LOG_NO_THREADS) Chris@16: # endif // defined(BOOST_LOG_DLL) Chris@16: Chris@16: Chris@16: namespace log { Chris@16: Chris@16: # if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES) Chris@16: Chris@16: inline namespace BOOST_LOG_VERSION_NAMESPACE {} Chris@16: } Chris@16: Chris@16: # define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE { Chris@16: # define BOOST_LOG_CLOSE_NAMESPACE }} Chris@16: Chris@16: # else Chris@16: Chris@16: namespace BOOST_LOG_VERSION_NAMESPACE {} Chris@16: Chris@16: using namespace BOOST_LOG_VERSION_NAMESPACE Chris@16: # if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && !defined(__clang__) Chris@16: __attribute__((__strong__)) Chris@16: # endif Chris@16: ; Chris@16: Chris@16: } Chris@16: Chris@16: # define BOOST_LOG_OPEN_NAMESPACE namespace log { namespace BOOST_LOG_VERSION_NAMESPACE { Chris@16: # define BOOST_LOG_CLOSE_NAMESPACE }} Chris@16: # endif Chris@16: Chris@16: #else // !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: Chris@16: namespace log {} Chris@16: # define BOOST_LOG_OPEN_NAMESPACE namespace log { Chris@16: # define BOOST_LOG_CLOSE_NAMESPACE } Chris@16: Chris@16: #endif // !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: Chris@101: #if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH) Chris@101: #pragma detect_mismatch("boost_log_abi", BOOST_PP_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE)) Chris@101: #endif Chris@101: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_