config.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2013.
  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 <limits.h> // To bring in libc macros
  24. #include <boost/config.hpp>
  25. #if defined(BOOST_NO_RTTI)
  26. # error Boost.Log: RTTI is required by the library
  27. #endif
  28. #if !defined(BOOST_WINDOWS)
  29. # ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
  30. # define BOOST_LOG_WITHOUT_DEBUG_OUTPUT
  31. # endif
  32. # ifndef BOOST_LOG_WITHOUT_EVENT_LOG
  33. # define BOOST_LOG_WITHOUT_EVENT_LOG
  34. # endif
  35. #endif
  36. #ifdef BOOST_HAS_PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39. #if defined(BOOST_MSVC)
  40. // For some reason MSVC 9.0 fails to link the library if static integral constants are defined in cpp
  41. # define BOOST_LOG_BROKEN_STATIC_CONSTANTS_LINKAGE
  42. # if _MSC_VER <= 1310
  43. // MSVC 7.1 sometimes fails to match out-of-class template function definitions with
  44. // their declarations if the return type or arguments of the functions involve typename keyword
  45. // and depend on the template parameters.
  46. # define BOOST_LOG_BROKEN_TEMPLATE_DEFINITION_MATCHING
  47. # endif
  48. # if _MSC_VER <= 1400
  49. // Older MSVC versions reject friend declarations for class template specializations
  50. # define BOOST_LOG_BROKEN_FRIEND_TEMPLATE_SPECIALIZATIONS
  51. # endif
  52. # if _MSC_VER <= 1600
  53. // MSVC up to 10.0 attempts to invoke copy constructor when initializing a const reference from rvalue returned from a function.
  54. // This fails when the returned value cannot be copied (only moved):
  55. //
  56. // class base {};
  57. // class derived : public base { BOOST_MOVABLE_BUT_NOT_COPYABLE(derived) };
  58. // derived foo();
  59. // base const& var = foo(); // attempts to call copy constructor of derived
  60. # define BOOST_LOG_BROKEN_REFERENCE_FROM_RVALUE_INIT
  61. # endif
  62. # if !defined(_STLPORT_VERSION)
  63. // MSVC 9.0 mandates packaging of STL classes, which apparently affects alignment and
  64. // makes alignment_of< T >::value no longer be a power of 2 for types that derive from STL classes.
  65. // This breaks type_with_alignment and everything that relies on it.
  66. // This doesn't happen with non-native STLs, such as STLPort. Strangely, this doesn't show with
  67. // STL classes themselves or most of the user-defined derived classes.
  68. // Not sure if that happens with other MSVC versions.
  69. // See: http://svn.boost.org/trac/boost/ticket/1946
  70. # define BOOST_LOG_BROKEN_STL_ALIGNMENT
  71. # endif
  72. #endif
  73. #if defined(BOOST_INTEL) || defined(__SUNPRO_CC)
  74. // Intel compiler and Sun Studio 12.3 have problems with friend declarations for nested class templates
  75. # define BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS
  76. #endif
  77. #if defined(BOOST_MSVC) && BOOST_MSVC <= 1600
  78. // MSVC cannot interpret constant expressions in certain contexts, such as non-type template parameters
  79. # define BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS
  80. #endif
  81. #if defined(__CYGWIN__)
  82. // Boost.ASIO is broken on Cygwin
  83. # define BOOST_LOG_NO_ASIO
  84. #endif
  85. #if !defined(BOOST_LOG_USE_NATIVE_SYSLOG) && defined(BOOST_LOG_NO_ASIO)
  86. # ifndef BOOST_LOG_WITHOUT_SYSLOG
  87. # define BOOST_LOG_WITHOUT_SYSLOG
  88. # endif
  89. #endif
  90. #if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 2)
  91. // GCC 4.1 and 4.2 have buggy anonymous namespaces support, which interferes with symbol linkage
  92. # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace anonymous {} using namespace anonymous; namespace anonymous
  93. #else
  94. # define BOOST_LOG_ANONYMOUS_NAMESPACE namespace
  95. #endif
  96. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || (defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 6))
  97. // GCC up to 4.6 (inclusively) did not support expanding template argument packs into non-variadic template arguments
  98. #define BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION
  99. #endif
  100. #if defined(_MSC_VER)
  101. # define BOOST_LOG_NO_VTABLE __declspec(novtable)
  102. #elif defined(__GNUC__)
  103. # define BOOST_LOG_NO_VTABLE
  104. #else
  105. # define BOOST_LOG_NO_VTABLE
  106. #endif
  107. // An MS-like compilers' extension that allows to optimize away the needless code
  108. #if defined(_MSC_VER)
  109. # define BOOST_LOG_ASSUME(expr) __assume(expr)
  110. #else
  111. # define BOOST_LOG_ASSUME(expr)
  112. #endif
  113. // The statement marking unreachable branches of code to avoid warnings
  114. #if defined(BOOST_CLANG)
  115. # if __has_builtin(__builtin_unreachable)
  116. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  117. # endif
  118. #elif defined(__GNUC__)
  119. # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
  120. # define BOOST_LOG_UNREACHABLE() __builtin_unreachable()
  121. # endif
  122. #elif defined(_MSC_VER)
  123. # define BOOST_LOG_UNREACHABLE() __assume(0)
  124. #endif
  125. #if !defined(BOOST_LOG_UNREACHABLE)
  126. # define BOOST_LOG_UNREACHABLE()
  127. #endif
  128. // Some compilers support a special attribute that shows that a function won't return
  129. #if defined(__GNUC__) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
  130. // GCC and Sun Studio 12 support attribute syntax
  131. # define BOOST_LOG_NORETURN __attribute__((noreturn))
  132. #elif defined (_MSC_VER)
  133. // Microsoft-compatible compilers go here
  134. # define BOOST_LOG_NORETURN __declspec(noreturn)
  135. #else
  136. // The rest compilers might emit bogus warnings about missing return statements
  137. // in functions with non-void return types when throw_exception is used.
  138. # define BOOST_LOG_NORETURN
  139. #endif
  140. // cxxabi.h availability macro
  141. #if defined(BOOST_CLANG)
  142. # if defined(__has_include) && __has_include(<cxxabi.h>)
  143. # define BOOST_LOG_HAS_CXXABI_H
  144. # endif
  145. #elif defined(__GNUC__) && !defined(__QNX__)
  146. # define BOOST_LOG_HAS_CXXABI_H
  147. #endif
  148. #if !defined(BOOST_LOG_BUILDING_THE_LIB)
  149. // Detect if we're dealing with dll
  150. # if defined(BOOST_LOG_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  151. # define BOOST_LOG_DLL
  152. # endif
  153. # if defined(BOOST_LOG_DLL)
  154. # if defined(BOOST_SYMBOL_IMPORT)
  155. # define BOOST_LOG_API BOOST_SYMBOL_IMPORT
  156. # elif defined(BOOST_HAS_DECLSPEC)
  157. # define BOOST_LOG_API __declspec(dllimport)
  158. # endif
  159. # endif
  160. # ifndef BOOST_LOG_API
  161. # define BOOST_LOG_API
  162. # endif
  163. //
  164. // Automatically link to the correct build variant where possible.
  165. //
  166. # if !defined(BOOST_ALL_NO_LIB)
  167. # if !defined(BOOST_LOG_NO_LIB)
  168. # define BOOST_LIB_NAME boost_log
  169. # if defined(BOOST_LOG_DLL)
  170. # define BOOST_DYN_LINK
  171. # endif
  172. # include <boost/config/auto_link.hpp>
  173. # endif
  174. // In static-library builds compilers ignore auto-link comments from Boost.Log binary to
  175. // other Boost libraries. We explicitly add comments here for other libraries.
  176. // In dynamic-library builds this is not needed.
  177. # if !defined(BOOST_LOG_DLL)
  178. # include <boost/system/config.hpp>
  179. # include <boost/filesystem/config.hpp>
  180. # if !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
  181. # define BOOST_LIB_NAME boost_date_time
  182. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
  183. # define BOOST_DYN_LINK
  184. # endif
  185. # include <boost/config/auto_link.hpp>
  186. # endif
  187. // Boost.Thread's config is included below, if needed
  188. # endif
  189. # endif // auto-linking disabled
  190. #else // !defined(BOOST_LOG_BUILDING_THE_LIB)
  191. # if defined(BOOST_LOG_DLL)
  192. # if defined(BOOST_SYMBOL_EXPORT)
  193. # define BOOST_LOG_API BOOST_SYMBOL_EXPORT
  194. # elif defined(BOOST_HAS_DECLSPEC)
  195. # define BOOST_LOG_API __declspec(dllexport)
  196. # endif
  197. # endif
  198. # ifndef BOOST_LOG_API
  199. # define BOOST_LOG_API BOOST_SYMBOL_VISIBLE
  200. # endif
  201. #endif // !defined(BOOST_LOG_BUILDING_THE_LIB)
  202. // By default we provide support for both char and wchar_t
  203. #if !defined(BOOST_LOG_WITHOUT_CHAR)
  204. # define BOOST_LOG_USE_CHAR
  205. #endif
  206. #if !defined(BOOST_LOG_WITHOUT_WCHAR_T)
  207. # define BOOST_LOG_USE_WCHAR_T
  208. #endif
  209. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  210. // Check if multithreading is supported
  211. # if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  212. # define BOOST_LOG_NO_THREADS
  213. # endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_HAS_THREADS)
  214. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  215. #if !defined(BOOST_LOG_NO_THREADS)
  216. // We need this header to (i) enable auto-linking with Boost.Thread and
  217. // (ii) to bring in configuration macros of Boost.Thread.
  218. # include <boost/thread/detail/config.hpp>
  219. #endif // !defined(BOOST_LOG_NO_THREADS)
  220. #if !defined(BOOST_LOG_NO_THREADS)
  221. # define BOOST_LOG_EXPR_IF_MT(expr) expr
  222. #else
  223. # undef BOOST_LOG_USE_COMPILER_TLS
  224. # define BOOST_LOG_EXPR_IF_MT(expr)
  225. #endif // !defined(BOOST_LOG_NO_THREADS)
  226. #if defined(BOOST_LOG_USE_COMPILER_TLS)
  227. # if defined(__GNUC__) || defined(__SUNPRO_CC)
  228. # define BOOST_LOG_TLS __thread
  229. # elif defined(BOOST_MSVC)
  230. # define BOOST_LOG_TLS __declspec(thread)
  231. # else
  232. # undef BOOST_LOG_USE_COMPILER_TLS
  233. # endif
  234. #endif // defined(BOOST_LOG_USE_COMPILER_TLS)
  235. namespace boost {
  236. // Setup namespace name
  237. #if !defined(BOOST_LOG_DOXYGEN_PASS)
  238. # if defined(BOOST_LOG_DLL)
  239. # if defined(BOOST_LOG_NO_THREADS)
  240. # define BOOST_LOG_VERSION_NAMESPACE v2_st
  241. # else
  242. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  243. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix
  244. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  245. # if defined(BOOST_LOG_USE_WINNT6_API)
  246. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6
  247. # else
  248. # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5
  249. # endif // defined(BOOST_LOG_USE_WINNT6_API)
  250. # else
  251. # define BOOST_LOG_VERSION_NAMESPACE v2_mt
  252. # endif
  253. # endif // defined(BOOST_LOG_NO_THREADS)
  254. # else
  255. # if defined(BOOST_LOG_NO_THREADS)
  256. # define BOOST_LOG_VERSION_NAMESPACE v2s_st
  257. # else
  258. # if defined(BOOST_THREAD_PLATFORM_PTHREAD)
  259. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix
  260. # elif defined(BOOST_THREAD_PLATFORM_WIN32)
  261. # if defined(BOOST_LOG_USE_WINNT6_API)
  262. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6
  263. # else
  264. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5
  265. # endif // defined(BOOST_LOG_USE_WINNT6_API)
  266. # else
  267. # define BOOST_LOG_VERSION_NAMESPACE v2s_mt
  268. # endif
  269. # endif // defined(BOOST_LOG_NO_THREADS)
  270. # endif // defined(BOOST_LOG_DLL)
  271. namespace log {
  272. # if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
  273. inline namespace BOOST_LOG_VERSION_NAMESPACE {}
  274. }
  275. # define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE {
  276. # define BOOST_LOG_CLOSE_NAMESPACE }}
  277. # else
  278. namespace BOOST_LOG_VERSION_NAMESPACE {}
  279. using namespace BOOST_LOG_VERSION_NAMESPACE
  280. # if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && !defined(__clang__)
  281. __attribute__((__strong__))
  282. # endif
  283. ;
  284. }
  285. # define BOOST_LOG_OPEN_NAMESPACE namespace log { namespace BOOST_LOG_VERSION_NAMESPACE {
  286. # define BOOST_LOG_CLOSE_NAMESPACE }}
  287. # endif
  288. #else // !defined(BOOST_LOG_DOXYGEN_PASS)
  289. namespace log {}
  290. # define BOOST_LOG_OPEN_NAMESPACE namespace log {
  291. # define BOOST_LOG_CLOSE_NAMESPACE }
  292. #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
  293. } // namespace boost
  294. #endif // BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_