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