config.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. #elif defined(__GNUC__)
  144. # define BOOST_LOG_NO_VTABLE
  145. #else
  146. # define BOOST_LOG_NO_VTABLE
  147. #endif
  148. // An MS-like compilers' extension that allows to optimize away the needless code
  149. #if defined(_MSC_VER)
  150. # define BOOST_LOG_ASSUME(expr) __assume(expr)
  151. #else
  152. # define BOOST_LOG_ASSUME(expr)
  153. #endif
  154. // The statement marking unreachable branches of code to avoid warnings
  155. #if defined(BOOST_CLANG)
  156. # if __has_builtin(__builtin_unreachable)
  157. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  158. # endif
  159. #elif defined(__GNUC__)
  160. # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  161. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  162. # endif
  163. #elif defined(_MSC_VER)
  164. # define BOOST_LOG_UNREACHABLE() __assume(0)
  165. #endif
  166. #if !defined(BOOST_LOG_UNREACHABLE)
  167. # define BOOST_LOG_UNREACHABLE()
  168. # define BOOST_LOG_UNREACHABLE_RETURN(r) return r
  169. #else
  170. # define BOOST_LOG_UNREACHABLE_RETURN(r) BOOST_LOG_UNREACHABLE()
  171. #endif
  172. // The macro efficiently returns a local lvalue from a function.
  173. // It employs NRVO, if supported by compiler, or uses a move constructor otherwise.
  174. #if defined(BOOST_HAS_NRVO)
  175. #define BOOST_LOG_NRVO_RESULT(x) x
  176. #else
  177. #define BOOST_LOG_NRVO_RESULT(x) boost::move(x)
  178. #endif
  179. // Some compilers support a special attribute that shows that a function won't return
  180. #if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
  181. // GCC and Sun Studio 12 support attribute syntax
  182. # define BOOST_LOG_NORETURN __attribute__((noreturn))
  183. #elif defined (_MSC_VER)
  184. // Microsoft-compatible compilers go here
  185. # define BOOST_LOG_NORETURN __declspec(noreturn)
  186. #else
  187. // The rest compilers might emit bogus warnings about missing return statements
  188. // in functions with non-void return types when throw_exception is used.
  189. # define BOOST_LOG_NORETURN
  190. #endif
  191. // Some compilers may require marking types that may alias other types
  192. #define BOOST_LOG_MAY_ALIAS BOOST_MAY_ALIAS
  193. #if !defined(BOOST_LOG_BUILDING_THE_LIB)
  194. // Detect if we're dealing with dll
  195. # if defined(BOOST_LOG_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  196. # define BOOST_LOG_DLL
  197. # endif
  198. # if defined(BOOST_LOG_DLL)
  199. # define BOOST_LOG_API BOOST_SYMBOL_IMPORT
  200. # else
  201. # define BOOST_LOG_API
  202. # endif
  203. //
  204. // Automatically link to the correct build variant where possible.
  205. //
  206. # if !defined(BOOST_ALL_NO_LIB)
  207. # if !defined(BOOST_LOG_NO_LIB)
  208. # define BOOST_LIB_NAME boost_log
  209. # if defined(BOOST_LOG_DLL)
  210. # define BOOST_DYN_LINK
  211. # endif
  212. # include <boost/config/auto_link.hpp>
  213. # endif
  214. // In static-library builds compilers ignore auto-link comments from Boost.Log binary to
  215. // other Boost libraries. We explicitly add comments here for other libraries.
  216. // In dynamic-library builds this is not needed.
  217. # if !defined(BOOST_LOG_DLL)
  218. # include <boost/system/config.hpp>
  219. # include <boost/filesystem/config.hpp>
  220. # if !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
  221. # define BOOST_LIB_NAME boost_date_time
  222. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
  223. # define BOOST_DYN_LINK
  224. # endif
  225. # include <boost/config/auto_link.hpp>
  226. # endif
  227. // Boost.Thread's config is included below, if needed
  228. # endif
  229. # endif // auto-linking disabled
  230. #else // !defined(BOOST_LOG_BUILDING_THE_LIB)
  231. # if defined(BOOST_LOG_DLL)
  232. # define BOOST_LOG_API BOOST_SYMBOL_EXPORT
  233. # else
  234. # define BOOST_LOG_API BOOST_SYMBOL_VISIBLE
  235. # endif
  236. #endif // !defined(BOOST_LOG_BUILDING_THE_LIB)
  237. // By default we provide support for both char and wchar_t
  238. #if !defined(BOOST_LOG_WITHOUT_CHAR)
  239. # define BOOST_LOG_USE_CHAR
  240. #endif
  241. #if !defined(BOOST_LOG_WITHOUT_WCHAR_T)
  242. # define BOOST_LOG_USE_WCHAR_T
  243. #endif
  244. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  245. // Check if multithreading is supported
  246. # if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  247. # define BOOST_LOG_NO_THREADS
  248. # endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  249. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  250. #if !defined(BOOST_LOG_NO_THREADS)
  251. // We need this header to (i) enable auto-linking with Boost.Thread and
  252. // (ii) to bring in configuration macros of Boost.Thread.
  253. # include <boost/thread/detail/config.hpp>
  254. #endif // !defined(BOOST_LOG_NO_THREADS)
  255. #if !defined(BOOST_LOG_NO_THREADS)
  256. # define BOOST_LOG_EXPR_IF_MT(expr) expr
  257. #else
  258. # undef BOOST_LOG_USE_COMPILER_TLS
  259. # define BOOST_LOG_EXPR_IF_MT(expr)
  260. #endif // !defined(BOOST_LOG_NO_THREADS)
  261. #if defined(BOOST_LOG_USE_COMPILER_TLS)
  262. # if defined(__GNUC__) || defined(__SUNPRO_CC)
  263. # define BOOST_LOG_TLS __thread
  264. # elif defined(BOOST_MSVC)
  265. # define BOOST_LOG_TLS __declspec(thread)
  266. # else
  267. # undef BOOST_LOG_USE_COMPILER_TLS
  268. # endif
  269. #endif // defined(BOOST_LOG_USE_COMPILER_TLS)
  270. #ifndef BOOST_LOG_CPU_CACHE_LINE_SIZE
  271. //! The macro defines the CPU cache line size for the target architecture. This is mostly used for optimization.
  272. #if defined(__s390__) || defined(__s390x__)
  273. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 256
  274. #elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
  275. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 128
  276. #else
  277. #define BOOST_LOG_CPU_CACHE_LINE_SIZE 64
  278. #endif
  279. #endif
  280. namespace boost {
  281. // Setup namespace name
  282. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  283. # if defined(BOOST_LOG_DLL)
  284. # if defined(BOOST_LOG_NO_THREADS)
  285. # define BOOST_LOG_VERSION_NAMESPACE v2_st
  286. # else
  287. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  288. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix
  289. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  290. # if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  291. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6
  292. # else
  293. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5
  294. # endif
  295. # else
  296. # define BOOST_LOG_VERSION_NAMESPACE v2_mt
  297. # endif
  298. # endif // defined(BOOST_LOG_NO_THREADS)
  299. # else
  300. # if defined(BOOST_LOG_NO_THREADS)
  301. # define BOOST_LOG_VERSION_NAMESPACE v2s_st
  302. # else
  303. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  304. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix
  305. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  306. # if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  307. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6
  308. # else
  309. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5
  310. # endif
  311. # else
  312. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt
  313. # endif
  314. # endif // defined(BOOST_LOG_NO_THREADS)
  315. # endif // defined(BOOST_LOG_DLL)
  316. namespace log {
  317. # if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
  318. inline namespace BOOST_LOG_VERSION_NAMESPACE {}
  319. # define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE {
  320. # define BOOST_LOG_CLOSE_NAMESPACE }}
  321. # elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40400
  322. // GCC 7 deprecated strong using directives but allows inline namespaces in C++03 mode since GCC 4.4.
  323. __extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {}
  324. # define BOOST_LOG_OPEN_NAMESPACE namespace log { __extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {
  325. # define BOOST_LOG_CLOSE_NAMESPACE }}
  326. # else
  327. namespace BOOST_LOG_VERSION_NAMESPACE {}
  328. using namespace BOOST_LOG_VERSION_NAMESPACE
  329. # if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && !defined(__clang__)
  330. __attribute__((__strong__))
  331. # endif
  332. ;
  333. # define BOOST_LOG_OPEN_NAMESPACE namespace log { namespace BOOST_LOG_VERSION_NAMESPACE {
  334. # define BOOST_LOG_CLOSE_NAMESPACE }}
  335. # endif
  336. } // namespace log
  337. #else // !defined(BOOST_LOG_DOXYGEN_PASS)
  338. namespace log {}
  339. # define BOOST_LOG_OPEN_NAMESPACE namespace log {
  340. # define BOOST_LOG_CLOSE_NAMESPACE }
  341. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  342. #if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
  343. #pragma detect_mismatch("boost_log_abi", BOOST_PP_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE))
  344. #endif
  345. } // namespace boost
  346. #endif // BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_