3 * Copyright (c) 1998-2002
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: regex extended config setup.
19 #ifndef BOOST_REGEX_CONFIG_HPP
20 #define BOOST_REGEX_CONFIG_HPP
22 * Borland C++ Fix/error check
23 * this has to go *before* we include any std lib headers:
25 #if defined(__BORLANDC__)
26 # include <boost/regex/config/borland.hpp>
28 #include <boost/version.hpp>
30 /*****************************************************************************
32 * Include all the headers we need here:
34 ****************************************************************************/
38 # ifndef BOOST_REGEX_USER_CONFIG
39 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
42 # include BOOST_REGEX_USER_CONFIG
44 # include <boost/config.hpp>
45 # include <boost/predef.h>
50 * don't include <boost/config.hpp> because that may
51 * do C++ specific things in future...
56 # define BOOST_MSVC _MSC_VER
60 /*****************************************************************************
62 * Boilerplate regex config options:
64 ****************************************************************************/
66 /* Obsolete macro, use BOOST_VERSION instead: */
67 #define BOOST_RE_VERSION 320
70 #if defined(_UNICODE) && !defined(UNICODE)
76 * Define a macro for the namespace that details are placed in, this includes the Boost
77 * version number to avoid mismatched header and library versions:
79 #define BOOST_REGEX_DETAIL_NS BOOST_JOIN(re_detail_, BOOST_VERSION)
82 * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
83 * masks to be combined, for example:
84 * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
88 # define BOOST_REGEX_BUGGY_CTYPE_FACET
92 * Intel C++ before 8.0 ends up with unresolved externals unless we turn off
93 * extern template support:
95 #if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
96 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
99 * Visual C++ doesn't support external templates with C++ extensions turned off:
101 #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
102 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
105 * Oracle compiler in C++11 mode doesn't like external templates for some reason:
108 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
111 * Shared regex lib will crash without this, frankly it looks a lot like a gcc bug:
113 #if defined(__MINGW32__)
114 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
118 * If there isn't good enough wide character support then there will
119 * be no wide character regular expressions:
121 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
122 # if !defined(BOOST_NO_WREGEX)
123 # define BOOST_NO_WREGEX
126 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
127 /* STLPort on IRIX is misconfigured: <cwctype> does not compile
128 * as a temporary fix include <wctype.h> instead and prevent inclusion
129 * of STLPort version of <cwctype> */
131 # define __STLPORT_CWCTYPE
132 # define _STLP_CWCTYPE
136 # include <boost/regex/config/cwchar.hpp>
142 * If Win32 support has been disabled for boost in general, then
143 * it is for regex in particular:
145 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
146 # define BOOST_REGEX_NO_W32
149 /* disable our own file-iterators and mapfiles if we can't
152 # if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
153 # define BOOST_REGEX_NO_FILEITER
155 #else // defined(_WIN32)
156 # if !defined(BOOST_HAS_DIRENT_H)
157 # define BOOST_REGEX_NO_FILEITER
161 /* backwards compatibitity: */
162 #if defined(BOOST_RE_NO_LIB)
163 # define BOOST_REGEX_NO_LIB
166 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
167 /* gcc on win32 has problems if you include <windows.h>
168 (sporadically generates bad code). */
169 # define BOOST_REGEX_NO_W32
171 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
172 # define BOOST_REGEX_NO_W32
175 /*****************************************************************************
177 * Wide character workarounds:
179 ****************************************************************************/
182 * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
183 * code may be built with wchar_t as unsigned short: basically when we're building
184 * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
185 * of the non-inline functions in the library, so that users can still link to the lib,
186 * irrespective of whether their own code is built with /Zc:wchar_t.
187 * Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
188 * the locale's <unsigned short> facets simply do not compile in that case.
189 * As we default to the C++ locale when compiling for the windows runtime we
190 * skip in this case aswell.
192 #if defined(__cplusplus) && \
193 (defined(BOOST_MSVC) || defined(__ICL)) && \
194 !defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
195 defined(BOOST_WINDOWS) && \
196 !defined(__SGI_STL_PORT) && \
197 !defined(_STLPORT_VERSION) && \
198 !defined(BOOST_RWSTD_VER) && \
199 ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
200 !BOOST_PLAT_WINDOWS_RUNTIME
201 # define BOOST_REGEX_HAS_OTHER_WCHAR_T
203 # pragma warning(push)
204 # pragma warning(disable : 4251 4231)
205 # if BOOST_MSVC < 1600
206 # pragma warning(disable : 4660)
209 # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
211 extern template class __declspec(dllimport) std::basic_string<unsigned short>;
214 # pragma warning(pop)
219 /*****************************************************************************
221 * Set up dll import/export options:
223 ****************************************************************************/
225 #ifndef BOOST_SYMBOL_EXPORT
226 # define BOOST_SYMBOL_EXPORT
227 # define BOOST_SYMBOL_IMPORT
230 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
231 # if defined(BOOST_REGEX_SOURCE)
232 # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
233 # define BOOST_REGEX_BUILD_DLL
235 # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
238 # define BOOST_REGEX_DECL
241 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
242 # define BOOST_LIB_NAME boost_regex
243 # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
244 # define BOOST_DYN_LINK
246 # ifdef BOOST_REGEX_DIAG
247 # define BOOST_LIB_DIAGNOSTIC
249 # include <boost/config/auto_link.hpp>
252 /*****************************************************************************
254 * Set up function call type:
256 ****************************************************************************/
258 #if defined(BOOST_MSVC) && defined(_MSC_EXTENSIONS)
259 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
260 # define BOOST_REGEX_CALL __cdecl
262 # define BOOST_REGEX_CALL __fastcall
264 # define BOOST_REGEX_CCALL __cdecl
267 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
268 # define BOOST_REGEX_CALL __fastcall
269 # define BOOST_REGEX_CCALL __stdcall
272 #ifndef BOOST_REGEX_CALL
273 # define BOOST_REGEX_CALL
275 #ifndef BOOST_REGEX_CCALL
276 #define BOOST_REGEX_CCALL
279 /*****************************************************************************
281 * Set up localisation model:
283 ****************************************************************************/
285 /* backwards compatibility: */
286 #ifdef BOOST_RE_LOCALE_C
287 # define BOOST_REGEX_USE_C_LOCALE
290 #ifdef BOOST_RE_LOCALE_CPP
291 # define BOOST_REGEX_USE_CPP_LOCALE
294 #if defined(__CYGWIN__)
295 # define BOOST_REGEX_USE_C_LOCALE
298 /* use C++ locale when targeting windows store */
299 #if BOOST_PLAT_WINDOWS_RUNTIME
300 # define BOOST_REGEX_USE_CPP_LOCALE
301 # define BOOST_REGEX_NO_WIN32_LOCALE
304 /* Win32 defaults to native Win32 locale: */
305 #if defined(_WIN32) && \
306 !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
307 !defined(BOOST_REGEX_USE_C_LOCALE) && \
308 !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
309 !defined(BOOST_REGEX_NO_W32) && \
310 !defined(BOOST_REGEX_NO_WIN32_LOCALE)
311 # define BOOST_REGEX_USE_WIN32_LOCALE
313 /* otherwise use C++ locale if supported: */
314 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
315 # define BOOST_REGEX_USE_CPP_LOCALE
317 /* otherwise use C+ locale: */
318 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
319 # define BOOST_REGEX_USE_C_LOCALE
322 #ifndef BOOST_REGEX_MAX_STATE_COUNT
323 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
327 /*****************************************************************************
329 * Error Handling for exception free compilers:
331 ****************************************************************************/
333 #ifdef BOOST_NO_EXCEPTIONS
335 * If there are no exceptions then we must report critical-errors
336 * the only way we know how; by terminating.
340 #include <boost/throw_exception.hpp>
342 # define BOOST_REGEX_NOEH_ASSERT(x)\
345 std::string s("Error: critical regex++ failure in: ");\
347 std::runtime_error e(s);\
348 boost::throw_exception(e);\
352 * With exceptions then error handling is taken care of and
353 * there is no need for these checks:
355 # define BOOST_REGEX_NOEH_ASSERT(x)
359 /*****************************************************************************
361 * Stack protection under MS Windows:
363 ****************************************************************************/
365 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
366 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
367 && !defined(__GNUC__) \
368 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
369 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
370 # define BOOST_REGEX_HAS_MS_STACK_GUARD
372 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
373 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
376 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
379 namespace BOOST_REGEX_DETAIL_NS{
381 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
389 /*****************************************************************************
391 * Algorithm selection and configuration:
393 ****************************************************************************/
395 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
396 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400))
397 # define BOOST_REGEX_RECURSIVE
399 # define BOOST_REGEX_NON_RECURSIVE
403 #ifdef BOOST_REGEX_NON_RECURSIVE
404 # ifdef BOOST_REGEX_RECURSIVE
405 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
407 # ifndef BOOST_REGEX_BLOCKSIZE
408 # define BOOST_REGEX_BLOCKSIZE 4096
410 # if BOOST_REGEX_BLOCKSIZE < 512
411 # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
413 # ifndef BOOST_REGEX_MAX_BLOCKS
414 # define BOOST_REGEX_MAX_BLOCKS 1024
416 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
417 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
419 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
420 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
425 /*****************************************************************************
427 * helper memory allocation functions:
429 ****************************************************************************/
431 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
432 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
434 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
435 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
440 /*****************************************************************************
444 ****************************************************************************/
446 #ifdef BOOST_REGEX_CONFIG_INFO
447 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
450 #if defined(BOOST_REGEX_DIAG)
451 # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
452 # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
453 # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
454 #ifdef BOOST_REGEX_USE_C_LOCALE
455 # pragma message ("Using C locale in regex traits class")
456 #elif BOOST_REGEX_USE_CPP_LOCALE
457 # pragma message ("Using C++ locale in regex traits class")
459 # pragma message ("Using Win32 locale in regex traits class")
461 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
462 # pragma message ("Dynamic linking enabled")
464 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
465 # pragma message ("Auto-linking disabled")
467 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
468 # pragma message ("Extern templates disabled")