Bond
 
Loading...
Searching...
No Matches
config.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <boost/config.hpp>
7
8#if !defined(BOND_COMPACT_BINARY_PROTOCOL) \
9 && !defined(BOND_SIMPLE_BINARY_PROTOCOL) \
10 && !defined(BOND_FAST_BINARY_PROTOCOL) \
11 && !defined(BOND_SIMPLE_JSON_PROTOCOL)
12
13#define BOND_COMPACT_BINARY_PROTOCOL
14#define BOND_SIMPLE_BINARY_PROTOCOL
15#define BOND_FAST_BINARY_PROTOCOL
16// BOND_SIMPLE_JSON_PROTOCOL disabled by default
17#endif
18
19// std::once seems problematic on Linux (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60662)
20// For now we use std::call_once only on MSVC and boost::call_once on GCC/Clang.
21#if defined(BOOST_NO_CXX11_HDR_MUTEX) || !defined(_MSC_VER)
22#define BOND_NO_CX11_HDR_MUTEX
23#endif
24
25// MSVC 14 (VS 2015) has only a dangerous partial implementation of expression SFINAE.
26#if defined(BOOST_NO_SFINAE_EXPR) || (defined(_MSC_VER) && (_MSC_VER < 1910))
27#define BOND_NO_SFINAE_EXPR
28#endif
29
30// MSVC doesn't set __cplusplus to the C++ standard level unless the extra
31// /Zc:__cplusplus switch is passed (to prevent breaking existing code that
32// assumes it is always equal to 199711L). We don't want to require users of
33// Bond to have to pass this, so we also check _MSVC_LANG, which is always
34// set to the C++ standard level since MSVC 2015.
35#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
36 #define BOND_CXX_17
37#endif
38
39#if defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
40#define BOND_NO_CXX14_RETURN_TYPE_DEDUCTION
41#endif
42
43#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
44#define BOND_NO_CXX14_GENERIC_LAMBDAS
45#endif
46
47#ifdef _MSC_VER
48#define BOND_CALL __cdecl
49#define BOND_NO_INLINE __declspec(noinline)
50#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
51#define BOND_CALL __attribute__((cdecl))
52#define BOND_NO_INLINE __attribute__((noinline))
53#else
54#define BOND_CALL
55#define BOND_NO_INLINE __attribute__((noinline))
56#endif
57
58#define BOND_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW
59#define BOND_NOEXCEPT_IF BOOST_NOEXCEPT_IF
60#define BOND_NOEXCEPT_EXPR BOOST_NOEXCEPT_EXPR
61#define BOND_CONSTEXPR BOOST_CONSTEXPR
62#define BOND_CONSTEXPR_OR_CONST BOOST_CONSTEXPR_OR_CONST
63#define BOND_STATIC_CONSTEXPR BOOST_STATIC_CONSTEXPR
64
65#if defined(BOOST_IF_CONSTEXPR)
66#define BOND_IF_CONSTEXPR BOOST_IF_CONSTEXPR
67#else
68#define BOND_IF_CONSTEXPR if
69#endif
70
71#define BOND_LIB_TYPE_HEADER 1
72#define BOND_LIB_TYPE_STATIC 2
73#define BOND_LIB_TYPE_DYNAMIC 3 // Not implemented
74
75#ifndef BOND_LIB_TYPE
76#define BOND_LIB_TYPE BOND_LIB_TYPE_HEADER
77#elif (BOND_LIB_TYPE != BOND_LIB_TYPE_HEADER) && (BOND_LIB_TYPE != BOND_LIB_TYPE_STATIC)
78#error Unsupported library type is defined for BOND_LIB_TYPE
79#endif
80
81#ifndef BOND_DETAIL_HEADER_ONLY_INLINE
82#if BOND_LIB_TYPE == BOND_LIB_TYPE_HEADER
83#define BOND_DETAIL_HEADER_ONLY_INLINE inline
84#else
85#define BOND_DETAIL_HEADER_ONLY_INLINE
86#endif
87#else
88#error BOND_DETAIL_HEADER_ONLY_INLINE is already defined
89#endif