]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines configuration macros used throughout the library. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_CONFIG_HPP | |
11 | #define BOOST_HANA_CONFIG_HPP | |
12 | ||
13 | #include <boost/hana/version.hpp> | |
14 | ||
15 | ||
16 | ////////////////////////////////////////////////////////////////////////////// | |
17 | // Detect the compiler | |
18 | ////////////////////////////////////////////////////////////////////////////// | |
19 | ||
20 | #if defined(_MSC_VER) && !defined(__clang__) // MSVC | |
21 | // This must be checked first, because otherwise it produces a fatal | |
22 | // error due to unrecognized #warning directives used below. | |
23 | # pragma message("Warning: the native Microsoft compiler is not supported due to lack of proper C++14 support.") | |
24 | ||
25 | #elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows) | |
26 | ||
27 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \ | |
28 | __clang_major__, __clang_minor__, __clang_patchlevel__) | |
29 | ||
30 | # if BOOST_HANA_CONFIG_CLANG < BOOST_HANA_CONFIG_VERSION(3, 5, 0) | |
31 | # warning "Versions of Clang prior to 3.5.0 are not supported by Hana." | |
32 | # endif | |
33 | ||
34 | # if _MSC_VER < 1900 | |
35 | # warning "Clang-cl is only supported with the -fms-compatibility-version parameter set to 19 and above." | |
36 | # endif | |
37 | ||
38 | #elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang | |
39 | ||
40 | # if __apple_build_version__ >= 6020049 | |
41 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0) | |
42 | # else | |
43 | # warning "Versions of Apple's Clang prior to the one shipped with Xcode 6.3 are not supported by Hana." | |
44 | # endif | |
45 | ||
46 | #elif defined(__clang__) // genuine Clang | |
47 | ||
48 | # define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \ | |
49 | __clang_major__, __clang_minor__, __clang_patchlevel__) | |
50 | ||
51 | # if BOOST_HANA_CONFIG_CLANG < BOOST_HANA_CONFIG_VERSION(3, 5, 0) | |
52 | # warning "Versions of Clang prior to 3.5.0 are not supported by Hana." | |
53 | # endif | |
54 | ||
55 | #elif defined(__GNUC__) // GCC | |
56 | ||
57 | # define BOOST_HANA_CONFIG_GCC BOOST_HANA_CONFIG_VERSION( \ | |
58 | __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) | |
59 | ||
60 | # if BOOST_HANA_CONFIG_GCC < BOOST_HANA_CONFIG_VERSION(6, 0, 0) | |
61 | # warning "Versions of GCC prior to 6.0.0 are not supported by Hana." | |
62 | # endif | |
63 | ||
64 | #else | |
65 | ||
66 | # warning "Your compiler is not officially supported by Hana or it was not detected properly." | |
67 | ||
68 | #endif | |
69 | ||
70 | ////////////////////////////////////////////////////////////////////////////// | |
71 | // Check the compiler for general C++14 capabilities | |
72 | ////////////////////////////////////////////////////////////////////////////// | |
73 | #if (__cplusplus < 201400) | |
74 | # if defined(_MSC_VER) | |
75 | # pragma message("Warning: Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'.") | |
76 | # else | |
77 | # warning "Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'." | |
78 | # endif | |
79 | #endif | |
80 | ||
81 | ////////////////////////////////////////////////////////////////////////////// | |
82 | // Detect the standard library | |
83 | ////////////////////////////////////////////////////////////////////////////// | |
84 | ||
85 | // We include this header, which normally defines the proper detection macros. | |
86 | // At least, libc++ and libstdc++ do. | |
87 | #include <cstddef> | |
88 | ||
89 | #if defined(_LIBCPP_VERSION) | |
90 | ||
91 | # define BOOST_HANA_CONFIG_LIBCPP BOOST_HANA_CONFIG_VERSION( \ | |
92 | ((_LIBCPP_VERSION) / 1000) % 10, 0, (_LIBCPP_VERSION) % 1000) | |
93 | ||
94 | # if BOOST_HANA_CONFIG_LIBCPP < BOOST_HANA_CONFIG_VERSION(1, 0, 101) | |
95 | # warning "Versions of libc++ prior to the one shipped with Clang 3.5.0 are not supported by Hana." | |
96 | # endif | |
97 | ||
98 | #elif defined(__GLIBCXX__) | |
99 | ||
100 | // We do not define a macro to keep track of libstdc++'s version, because | |
101 | // we have no scalable way of associating a value of __GLIBCXX__ to the | |
102 | // corresponding GCC release. Instead, we just check that the release date | |
103 | // of the libstdc++ in use is recent enough, which should indicate that it | |
104 | // was released with a GCC >= 5.1, which in turn indicates good enough C++14 | |
105 | // support. | |
106 | # if __GLIBCXX__ < 20150422 // --> the libstdc++ shipped with GCC 5.1.0 | |
107 | # warning "Versions of libstdc++ prior to the one shipped with GCC 5.1.0 are not supported by Hana for lack of full C++14 support." | |
108 | # endif | |
109 | ||
110 | # define BOOST_HANA_CONFIG_LIBSTDCXX | |
111 | ||
112 | #elif defined(_MSC_VER) | |
113 | ||
114 | # define BOOST_HANA_CONFIG_LIBMSVCCXX | |
115 | ||
116 | #else | |
117 | ||
118 | # warning "Your standard library is not officially supported by Hana or it was not detected properly." | |
119 | ||
120 | #endif | |
121 | ||
122 | ||
123 | ////////////////////////////////////////////////////////////////////////////// | |
124 | // Caveats and other compiler-dependent options | |
125 | ////////////////////////////////////////////////////////////////////////////// | |
126 | ||
127 | // BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA enables some constructs requiring | |
128 | // `constexpr` lambdas, which are not in the language (yet). | |
129 | // Currently always disabled. | |
130 | // | |
131 | // BOOST_HANA_CONSTEXPR_LAMBDA expands to `constexpr` if constexpr lambdas | |
132 | // are supported and to nothing otherwise. | |
133 | #if 0 | |
134 | # define BOOST_HANA_CONFIG_HAS_CONSTEXPR_LAMBDA | |
135 | # define BOOST_HANA_CONSTEXPR_LAMBDA constexpr | |
136 | #else | |
137 | # define BOOST_HANA_CONSTEXPR_LAMBDA /* nothing */ | |
138 | #endif | |
139 | ||
140 | // The std::tuple adapter is broken on libc++ prior to the one shipped | |
141 | // with Clang 3.7.0. | |
142 | #if defined(BOOST_HANA_CONFIG_LIBCPP) && \ | |
143 | BOOST_HANA_CONFIG_LIBCPP < BOOST_HANA_CONFIG_VERSION(1, 0, 101) | |
144 | # define BOOST_HANA_CONFIG_HAS_NO_STD_TUPLE_ADAPTER | |
145 | #endif | |
146 | ||
147 | // There's a bug in std::tuple_cat in libc++ right now. | |
148 | // See http://llvm.org/bugs/show_bug.cgi?id=22806. | |
149 | #if defined(BOOST_HANA_CONFIG_LIBCPP) | |
150 | # define BOOST_HANA_CONFIG_LIBCPP_HAS_BUG_22806 | |
151 | #endif | |
152 | ||
153 | ////////////////////////////////////////////////////////////////////////////// | |
154 | // Namespace macros | |
155 | ////////////////////////////////////////////////////////////////////////////// | |
156 | #define BOOST_HANA_NAMESPACE_BEGIN namespace boost { namespace hana { | |
157 | ||
158 | #define BOOST_HANA_NAMESPACE_END }} | |
159 | ||
160 | ////////////////////////////////////////////////////////////////////////////// | |
161 | // Library features and options that can be tweaked by users | |
162 | ////////////////////////////////////////////////////////////////////////////// | |
163 | ||
164 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) || \ | |
165 | (defined(NDEBUG) && !defined(BOOST_HANA_CONFIG_DISABLE_ASSERTIONS)) | |
166 | //! @ingroup group-config | |
167 | //! Disables the `BOOST_HANA_*_ASSERT` macro & friends. | |
168 | //! | |
169 | //! When this macro is defined, the `BOOST_HANA_*_ASSERT` macro & friends | |
170 | //! are disabled, i.e. they expand to nothing. | |
171 | //! | |
172 | //! This macro is defined automatically when `NDEBUG` is defined. It can | |
173 | //! also be defined by users before including this header or defined on | |
174 | //! the command line. | |
175 | # define BOOST_HANA_CONFIG_DISABLE_ASSERTIONS | |
176 | #endif | |
177 | ||
178 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
179 | //! @ingroup group-config | |
180 | //! Disables concept checks in interface methods. | |
181 | //! | |
182 | //! When this macro is not defined (the default), tag-dispatched methods | |
183 | //! will make sure the arguments they are passed are models of the proper | |
184 | //! concept(s). This can be very helpful in catching programming errors, | |
185 | //! but it is also slightly less compile-time efficient. You should | |
186 | //! probably always leave the checks enabled (and hence never define this | |
187 | //! macro), except perhaps in translation units that are compiled very | |
188 | //! often but whose code using Hana is modified very rarely. | |
189 | # define BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS | |
190 | #endif | |
191 | ||
192 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
193 | //! @ingroup group-config | |
194 | //! Enables usage of the "string literal operator template" GNU extension. | |
195 | //! | |
196 | //! That operator is not part of the language yet, but it is supported by | |
197 | //! both Clang and GCC. This operator allows Hana to provide the nice `_s` | |
198 | //! user-defined literal for creating compile-time strings. | |
199 | //! | |
200 | //! When this macro is not defined, the GNU extension will be not used | |
201 | //! by Hana. Because this is a non-standard extension, the macro is not | |
202 | //! defined by default. | |
203 | # define BOOST_HANA_CONFIG_ENABLE_STRING_UDL | |
204 | #endif | |
205 | ||
206 | #if defined(BOOST_HANA_DOXYGEN_INVOKED) | |
207 | //! @ingroup group-config | |
208 | //! Enables additional assertions and sanity checks to be done by Hana. | |
209 | //! | |
210 | //! When this macro is defined (it is __not defined__ by default), | |
211 | //! additional sanity checks may be done by Hana. These checks may | |
212 | //! be costly to perform, either in terms of compilation time or in | |
213 | //! terms of execution time. These checks may help debugging an | |
214 | //! application during its initial development, but they should not | |
215 | //! be enabled as part of the normal configuration. | |
216 | # define BOOST_HANA_CONFIG_ENABLE_DEBUG_MODE | |
217 | #endif | |
218 | ||
219 | #endif // !BOOST_HANA_CONFIG_HPP |