config.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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 config.hpp
  9. * \author Andrey Semashev
  10. * \date 08.03.2007
  11. *
  12. * \brief This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file
  14. * internal configuration macros are defined.
  15. */
  16. #ifndef BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_
  17. #define BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_
  18. // This check must be before any system headers are included, or __MSVCRT_VERSION__ may get defined to 0x0600
  19. #if defined(__MINGW32__) && !defined(__MSVCRT_VERSION__)
  20. // Target MinGW headers to at least MSVC 7.0 runtime by default. This will enable some useful functions.
  21. #define __MSVCRT_VERSION__ 0x0700
  22. #endif
  23. #include <boost/predef/os.h>
  24. // Try including WinAPI config as soon as possible so that any other headers don't include Windows SDK headers
  25. #if defined(BOOST_OS_WINDOWS_AVAILABLE)
  26. #include <boost/winapi/config.hpp>
  27. #endif
  28. #include <limits.h> // To bring in libc macros
  29. #include <boost/config.hpp>
  30. // The library requires dynamic_cast in a few places
  31. #if defined(BOOST_NO_RTTI)
  32. # error Boost.Log: RTTI is required by the library
  33. #endif
  34. #if defined(_MSC_VER) && _MSC_VER >= 1600
  35. # define BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH
  36. #endif
  37. #if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
  38. #include <boost/preprocessor/stringize.hpp>
  39. #endif
  40. #if !defined(BOOST_WINDOWS)
  41. # ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
  42. # define BOOST_LOG_WITHOUT_DEBUG_OUTPUT
  43. # endif
  44. # ifndef BOOST_LOG_WITHOUT_EVENT_LOG
  45. # define BOOST_LOG_WITHOUT_EVENT_LOG
  46. # endif
  47. #endif
  48. #ifdef BOOST_HAS_PRAGMA_ONCE
  49. #pragma once
  50. #endif
  51. #if defined(BOOST_MSVC)
  52. // For some reason MSVC 9.0 fails to link the library if static integral constants are defined in cpp
  53. # define BOOST_LOG_BROKEN_STATIC_CONSTANTS_LINKAGE
  54. # if _MSC_VER <= 1310
  55. // MSVC 7.1 sometimes fails to match out-of-class template function definitions with
  56. // their declarations if the return type or arguments of the functions involve typename keyword
  57. // and depend on the template parameters.
  58. # define BOOST_LOG_BROKEN_TEMPLATE_DEFINITION_MATCHING
  59. # endif
  60. # if _MSC_VER <= 1400
  61. // Older MSVC versions reject friend declarations for class template specializations
  62. # define BOOST_LOG_BROKEN_FRIEND_TEMPLATE_SPECIALIZATIONS
  63. # endif
  64. # if _MSC_VER <= 1600
  65. // MSVC up to 10.0 attempts to invoke copy constructor when initializing a const reference from rvalue returned from a function.
  66. // This fails when the returned value cannot be copied (only moved):
  67. //
  68. // class base {};
  69. // class derived : public base { BOOST_MOVABLE_BUT_NOT_COPYABLE(derived) };
  70. // derived foo();
  71. // base const& var = foo(); // attempts to call copy constructor of derived
  72. # define BOOST_LOG_BROKEN_REFERENCE_FROM_RVALUE_INIT
  73. # endif
  74. # if !defined(_STLPORT_VERSION)
  75. // MSVC 9.0 mandates packaging of STL classes, which apparently affects alignment and
  76. // makes alignment_of< T >::value no longer be a power of 2 for types that derive from STL classes.
  77. // This breaks type_with_alignment and everything that relies on it.
  78. // This doesn't happen with non-native STLs, such as STLPort. Strangely, this doesn't show with
  79. // STL classes themselves or most of the user-defined derived classes.
  80. // Not sure if that happens with other MSVC versions.
  81. // See: http://svn.boost.org/trac/boost/ticket/1946
  82. # define BOOST_LOG_BROKEN_STL_ALIGNMENT
  83. # endif
  84. #endif
  85. #if defined(BOOST_INTEL) || defined(__SUNPRO_CC)
  86. // Intel compiler and Sun Studio 12.3 have problems with friend declarations for nested class templates
  87. # define BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS
  88. #endif
  89. #if defined(BOOST_MSVC) && BOOST_MSVC <= 1600
  90. // MSVC cannot interpret constant expressions in certain contexts, such as non-type template parameters
  91. # define BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS
  92. #endif
  93. #if defined(BOOST_NO_CXX11_HDR_CODECVT)
  94. // The compiler does not support std::codecvt<char16_t> and std::codecvt<char32_t> specializations.
  95. // The BOOST_NO_CXX11_HDR_CODECVT means there's no usable <codecvt>, which is slightly different from this macro.
  96. // But in order for <codecvt> to be implemented the std::codecvt specializations have to be implemented as well.
  97. # define BOOST_LOG_NO_CXX11_CODECVT_FACETS
  98. #endif
  99. #if defined(__CYGWIN__)
  100. // Boost.ASIO is broken on Cygwin
  101. # define BOOST_LOG_NO_ASIO
  102. #endif
  103. #if defined(__VXWORKS__)
  104. # define BOOST_LOG_NO_GETPGRP
  105. # define BOOST_LOG_NO_GETSID
  106. // for _WRS_CONFIG_USER_MANAGEMENT used below
  107. # include <vsbConfig.h>
  108. #endif
  109. #if (!defined(__CRYSTAX__) && defined(__ANDROID__) && (__ANDROID_API__+0) < 21) \
  110. || (defined(__VXWORKS__) && !defined(_WRS_CONFIG_USER_MANAGEMENT))
  111. // Until Android API version 21 Google NDK does not provide getpwuid_r
  112. # define BOOST_LOG_NO_GETPWUID_R
  113. #endif
  114. #if !defined(BOOST_LOG_USE_NATIVE_SYSLOG) && defined(BOOST_LOG_NO_ASIO)
  115. # ifndef BOOST_LOG_WITHOUT_SYSLOG
  116. # define BOOST_LOG_WITHOUT_SYSLOG
  117. # endif
  118. #endif
  119. #if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 2)
  120. // GCC 4.1 and 4.2 have buggy anonymous namespaces support, which interferes with symbol linkage
  121. # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace anonymous {} using namespace anonymous; namespace anonymous
  122. #else
  123. # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace
  124. #endif
  125. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || (defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 6))
  126. // GCC up to 4.6 (inclusively) did not support expanding template argument packs into non-variadic template arguments
  127. #define BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION
  128. #endif
  129. #if defined(BOOST_NO_CXX11_CONSTEXPR) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
  130. // GCC 4.6 does not support in-class brace initializers for static constexpr array members
  131. #define BOOST_LOG_NO_CXX11_CONSTEXPR_DATA_MEMBER_BRACE_INITIALIZERS
  132. #endif
  133. #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
  134. // GCC 4.6 cannot handle a defaulted function with noexcept specifier
  135. #define BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
  136. #endif
  137. #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_CLANG) && (((__clang_major__+0) == 3) && ((__clang_minor__+0) <= 1)))
  138. // Clang 3.1 cannot handle a defaulted constexpr constructor in some cases (presumably, if the class contains a member with a constexpr constructor)
  139. #define BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS
  140. #endif
  141. #if defined(_MSC_VER)
  142. # define BOOST_LOG_NO_VTABLE __declspec(novtable)
  143. #else
  144. # define BOOST_LOG_NO_VTABLE
  145. #endif
  146. // An MS-like compilers' extension that allows to optimize away the needless code
  147. #if defined(_MSC_VER)
  148. # define BOOST_LOG_ASSUME(expr) __assume(expr)
  149. #else
  150. # define BOOST_LOG_ASSUME(expr)
  151. #endif
  152. // The statement marking unreachable branches of code to avoid warnings
  153. #if defined(BOOST_CLANG)
  154. # if __has_builtin(__builtin_unreachable)
  155. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  156. # endif
  157. #elif defined(__GNUC__)
  158. # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  159. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  160. # endif
  161. #elif defined(_MSC_VER)
  162. # define BOOST_LOG_UNREACHABLE() __assume(0)
  163. #endif
  164. #if !defined(BOOST_LOG_UNREACHABLE)
  165. # define BOOST_LOG_UNREACHABLE()
  166. # define BOOST_LOG_UNREACHABLE_RETURN(r) return r
  167. #else
  168. # define BOOST_LOG_UNREACHABLE_RETURN(r) BOOST_LOG_UNREACHABLE()
  169. #endif
  170. // The macro efficiently returns a local lvalue from a function.
  171. // It employs NRVO, if supported by compiler, or uses a move constructor otherwise.
  172. #if defined(BOOST_HAS_NRVO)
  173. #define BOOST_LOG_NRVO_RESULT(x) x
  174. #else
  175. #define BOOST_LOG_NRVO_RESULT(x) boost::move(x)
  176. #endif
  177. // Some compilers support a special attribute that shows that a function won't return
  178. #if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
  179. // GCC and Sun Studio 12 support attribute syntax
  180. # define BOOST_LOG_NORETURN __attribute__((noreturn))
  181. #elif defined (_MSC_VER)
  182. // Microsoft-compatible compilers go here
  183. # define BOOST_LOG_NORETURN __declspec(noreturn)
  184. #else
  185. // The rest compilers might emit bogus warnings about missing return statements
  186. // in functions with non-void return types when throw_exception is used.
  187. # define BOOST_LOG_NORETURN
  188. #endif
  189. // Some compilers may require marking types that may alias other types
  190. #define BOOST_LOG_MAY_ALIAS BOOST_MAY_ALIAS
  191. #if !defined(BOOST_LOG_BUILDING_THE_LIB)
  192. // Detect if we're dealing with dll
  193. # if defined(BOOST_LOG_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  194. # define BOOST_LOG_DLL
  195. # endif
  196. # if defined(BOOST_LOG_DLL)
  197. # define BOOST_LOG_API BOOST_SYMBOL_IMPORT
  198. # else
  199. # define BOOST_LOG_API
  200. # endif
  201. //
  202. // Automatically link to the correct build variant where possible.
  203. //
  204. # if !defined(BOOST_ALL_NO_LIB)
  205. # if !defined(BOOST_LOG_NO_LIB)
  206. # define BOOST_LIB_NAME boost_log
  207. # if defined(BOOST_LOG_DLL)
  208. # define BOOST_DYN_LINK
  209. # endif
  210. # include <boost/config/auto_link.hpp>
  211. # endif
  212. // In static-library builds compilers ignore auto-link comments from Boost.Log binary to
  213. // other Boost libraries. We explicitly add comments here for other libraries.
  214. // In dynamic-library builds this is not needed.
  215. # if !defined(BOOST_LOG_DLL)
  216. # include <boost/system/config.hpp>
  217. # include <boost/filesystem/config.hpp>
  218. # if !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
  219. # define BOOST_LIB_NAME boost_date_time
  220. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
  221. # define BOOST_DYN_LINK
  222. # endif
  223. # include <boost/config/auto_link.hpp>
  224. # endif
  225. // Boost.Thread's config is included below, if needed
  226. # endif
  227. # endif // auto-linking disabled
  228. #else // !defined(BOOST_LOG_BUILDING_THE_LIB)
  229. # if defined(BOOST_LOG_DLL)
  230. # define BOOST_LOG_API BOOST_SYMBOL_EXPORT
  231. # else
  232. # define BOOST_LOG_API BOOST_SYMBOL_VISIBLE
  233. # endif
  234. #endif // !defined(BOOST_LOG_BUILDING_THE_LIB)
  235. // By default we provide support for both char and wchar_t
  236. #if !defined(BOOST_LOG_WITHOUT_CHAR)
  237. # define BOOST_LOG_USE_CHAR
  238. #endif
  239. #if !defined(BOOST_LOG_WITHOUT_WCHAR_T)
  240. # define BOOST_LOG_USE_WCHAR_T
  241. #endif
  242. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  243. // Check if multithreading is supported
  244. # if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  245. # define BOOST_LOG_NO_THREADS
  246. # endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  247. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  248. #if !defined(BOOST_LOG_NO_THREADS)
  249. // We need this header to (i) enable auto-linking with Boost.Thread and
  250. // (ii) to bring in configuration macros of Boost.Thread.
  251. # include <boost/thread/detail/config.hpp>
  252. #endif // !defined(BOOST_LOG_NO_THREADS)
  253. #if !defined(BOOST_LOG_NO_THREADS)
  254. # define BOOST_LOG_EXPR_IF_MT(expr) expr
  255. #else
  256. # undef BOOST_LOG_USE_COMPILER_TLS
  257. # define BOOST_LOG_EXPR_IF_MT(expr)
  258. #endif // !defined(BOOST_LOG_NO_THREADS)
  259. #if defined(BOOST_LOG_USE_COMPILER_TLS)
  260. # if defined(__GNUC__) || defined(__SUNPRO_CC)
  261. # define BOOST_LOG_TLS __thread
  262. # elif defined(BOOST_MSVC)
  263. # define BOOST_LOG_TLS __declspec(thread)
  264. # else
  265. # undef BOOST_LOG_USE_COMPILER_TLS
  266. # endif
  267. #endif // defined(BOOST_LOG_USE_COMPILER_TLS)
  268. #ifndef BOOST_LOG_CPU_CACHE_LINE_SIZE
  269. //! The macro defines the CPU cache line size for the target architecture. This is mostly used for optimization.
  270. #if defined(__s390__) || defined(__s390x__)
  271. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 256
  272. #elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
  273. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 128
  274. #else
  275. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 64
  276. #endif
  277. #endif
  278. namespace boost {
  279. // Setup namespace name
  280. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  281. # if defined(BOOST_LOG_DLL)
  282. # if defined(BOOST_LOG_NO_THREADS)
  283. # define BOOST_LOG_VERSION_NAMESPACE v2_st
  284. # else
  285. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  286. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix
  287. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  288. # if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  289. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6
  290. # else
  291. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5
  292. # endif
  293. # else
  294. # define BOOST_LOG_VERSION_NAMESPACE v2_mt
  295. # endif
  296. # endif // defined(BOOST_LOG_NO_THREADS)
  297. # else
  298. # if defined(BOOST_LOG_NO_THREADS)
  299. # define BOOST_LOG_VERSION_NAMESPACE v2s_st
  300. # else
  301. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  302. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix
  303. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  304. # if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  305. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6
  306. # else
  307. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5
  308. # endif
  309. # else
  310. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt
  311. # endif
  312. # endif // defined(BOOST_LOG_NO_THREADS)
  313. # endif // defined(BOOST_LOG_DLL)
  314. namespace log {
  315. # if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
  316. inline namespace BOOST_LOG_VERSION_NAMESPACE {}
  317. # define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE {
  318. # define BOOST_LOG_CLOSE_NAMESPACE }}
  319. # elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40400
  320. // GCC 7 deprecated strong using directives but allows inline namespaces in C++03 mode since GCC 4.4.
  321. __extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {}
  322. # define BOOST_LOG_OPEN_NAMESPACE namespace log { __extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {
  323. # define BOOST_LOG_CLOSE_NAMESPACE }}
  324. # else
  325. namespace BOOST_LOG_VERSION_NAMESPACE {}
  326. using namespace BOOST_LOG_VERSION_NAMESPACE
  327. # if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && !defined(__clang__)
  328. __attribute__((__strong__))
  329. # endif
  330. ;
  331. # define BOOST_LOG_OPEN_NAMESPACE namespace log { namespace BOOST_LOG_VERSION_NAMESPACE {
  332. # define BOOST_LOG_CLOSE_NAMESPACE }}
  333. # endif
  334. } // namespace log
  335. #else // !defined(BOOST_LOG_DOXYGEN_PASS)
  336. namespace log {}
  337. # define BOOST_LOG_OPEN_NAMESPACE namespace log {
  338. # define BOOST_LOG_CLOSE_NAMESPACE }
  339. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  340. #if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
  341. #pragma detect_mismatch("boost_log_abi", BOOST_PP_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE))
  342. #endif
  343. } // namespace boost
  344. #endif // BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_