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
117 * Clang fails to export template instances with -fvisibility=hidden, see
118 * https://github.com/boostorg/regex/issues/49
121 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
124 /* We get multiply defined symbols without this: */
125 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
129 * If there isn't good enough wide character support then there will
130 * be no wide character regular expressions:
132 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
133 # if !defined(BOOST_NO_WREGEX)
134 # define BOOST_NO_WREGEX
137 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
138 /* STLPort on IRIX is misconfigured: <cwctype> does not compile
139 * as a temporary fix include <wctype.h> instead and prevent inclusion
140 * of STLPort version of <cwctype> */
142 # define __STLPORT_CWCTYPE
143 # define _STLP_CWCTYPE
147 # include <boost/regex/config/cwchar.hpp>
153 * If Win32 support has been disabled for boost in general, then
154 * it is for regex in particular:
156 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
157 # define BOOST_REGEX_NO_W32
160 /* disable our own file-iterators and mapfiles if we can't
163 # if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
164 # define BOOST_REGEX_NO_FILEITER
166 #else /* defined(_WIN32) */
167 # if !defined(BOOST_HAS_DIRENT_H)
168 # define BOOST_REGEX_NO_FILEITER
172 /* backwards compatibitity: */
173 #if defined(BOOST_RE_NO_LIB)
174 # define BOOST_REGEX_NO_LIB
177 #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__))
178 /* gcc on win32 has problems if you include <windows.h>
179 (sporadically generates bad code). */
180 # define BOOST_REGEX_NO_W32
182 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
183 # define BOOST_REGEX_NO_W32
186 /*****************************************************************************
188 * Wide character workarounds:
190 ****************************************************************************/
193 * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
194 * code may be built with wchar_t as unsigned short: basically when we're building
195 * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
196 * of the non-inline functions in the library, so that users can still link to the lib,
197 * irrespective of whether their own code is built with /Zc:wchar_t.
198 * Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
199 * the locale's <unsigned short> facets simply do not compile in that case.
200 * As we default to the C++ locale when compiling for the windows runtime we
201 * skip in this case aswell.
203 #if defined(__cplusplus) && \
204 (defined(BOOST_MSVC) || defined(__ICL)) && \
205 !defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
206 defined(BOOST_WINDOWS) && \
207 !defined(__SGI_STL_PORT) && \
208 !defined(_STLPORT_VERSION) && \
209 !defined(BOOST_RWSTD_VER) && \
210 ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
211 !BOOST_PLAT_WINDOWS_RUNTIME
212 # define BOOST_REGEX_HAS_OTHER_WCHAR_T
214 # pragma warning(push)
215 # pragma warning(disable : 4251)
216 #if BOOST_MSVC < 1700
217 # pragma warning(disable : 4231)
219 # if BOOST_MSVC < 1600
220 # pragma warning(disable : 4660)
223 # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
225 extern template class __declspec(dllimport) std::basic_string<unsigned short>;
228 # pragma warning(pop)
233 /*****************************************************************************
235 * Set up dll import/export options:
237 ****************************************************************************/
239 #ifndef BOOST_SYMBOL_EXPORT
240 # define BOOST_SYMBOL_EXPORT
241 # define BOOST_SYMBOL_IMPORT
244 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
245 # if defined(BOOST_REGEX_SOURCE)
246 # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
247 # define BOOST_REGEX_BUILD_DLL
249 # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
252 # define BOOST_REGEX_DECL
255 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
256 # define BOOST_LIB_NAME boost_regex
257 # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
258 # define BOOST_DYN_LINK
260 # ifdef BOOST_REGEX_DIAG
261 # define BOOST_LIB_DIAGNOSTIC
263 # include <boost/config/auto_link.hpp>
266 /*****************************************************************************
268 * Set up function call type:
270 ****************************************************************************/
272 #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS)
273 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
274 # define BOOST_REGEX_CALL __cdecl
276 # define BOOST_REGEX_CALL __fastcall
278 # define BOOST_REGEX_CCALL __cdecl
281 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
282 # define BOOST_REGEX_CALL __fastcall
283 # define BOOST_REGEX_CCALL __stdcall
286 #ifndef BOOST_REGEX_CALL
287 # define BOOST_REGEX_CALL
289 #ifndef BOOST_REGEX_CCALL
290 #define BOOST_REGEX_CCALL
293 /*****************************************************************************
295 * Set up localisation model:
297 ****************************************************************************/
299 /* backwards compatibility: */
300 #ifdef BOOST_RE_LOCALE_C
301 # define BOOST_REGEX_USE_C_LOCALE
304 #ifdef BOOST_RE_LOCALE_CPP
305 # define BOOST_REGEX_USE_CPP_LOCALE
308 #if defined(__CYGWIN__)
309 # define BOOST_REGEX_USE_C_LOCALE
312 /* use C++ locale when targeting windows store */
313 #if BOOST_PLAT_WINDOWS_RUNTIME
314 # define BOOST_REGEX_USE_CPP_LOCALE
315 # define BOOST_REGEX_NO_WIN32_LOCALE
318 /* Win32 defaults to native Win32 locale: */
319 #if defined(_WIN32) && \
320 !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
321 !defined(BOOST_REGEX_USE_C_LOCALE) && \
322 !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
323 !defined(BOOST_REGEX_NO_W32) && \
324 !defined(BOOST_REGEX_NO_WIN32_LOCALE)
325 # define BOOST_REGEX_USE_WIN32_LOCALE
327 /* otherwise use C++ locale if supported: */
328 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
329 # define BOOST_REGEX_USE_CPP_LOCALE
331 /* otherwise use C+ locale: */
332 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
333 # define BOOST_REGEX_USE_C_LOCALE
336 #ifndef BOOST_REGEX_MAX_STATE_COUNT
337 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
341 /*****************************************************************************
343 * Error Handling for exception free compilers:
345 ****************************************************************************/
347 #ifdef BOOST_NO_EXCEPTIONS
349 * If there are no exceptions then we must report critical-errors
350 * the only way we know how; by terminating.
354 #include <boost/throw_exception.hpp>
356 # define BOOST_REGEX_NOEH_ASSERT(x)\
359 std::string s("Error: critical regex++ failure in: ");\
361 std::runtime_error e(s);\
362 boost::throw_exception(e);\
366 * With exceptions then error handling is taken care of and
367 * there is no need for these checks:
369 # define BOOST_REGEX_NOEH_ASSERT(x)
373 /*****************************************************************************
375 * Stack protection under MS Windows:
377 ****************************************************************************/
379 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
380 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
381 && !defined(__GNUC__) \
382 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
383 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
384 # define BOOST_REGEX_HAS_MS_STACK_GUARD
386 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
387 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
390 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
393 namespace BOOST_REGEX_DETAIL_NS{
395 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
403 /*****************************************************************************
405 * Algorithm selection and configuration:
407 ****************************************************************************/
409 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
410 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400))
411 # define BOOST_REGEX_RECURSIVE
413 # define BOOST_REGEX_NON_RECURSIVE
417 #ifdef BOOST_REGEX_NON_RECURSIVE
418 # ifdef BOOST_REGEX_RECURSIVE
419 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
421 # ifndef BOOST_REGEX_BLOCKSIZE
422 # define BOOST_REGEX_BLOCKSIZE 4096
424 # if BOOST_REGEX_BLOCKSIZE < 512
425 # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
427 # ifndef BOOST_REGEX_MAX_BLOCKS
428 # define BOOST_REGEX_MAX_BLOCKS 1024
430 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
431 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
433 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
434 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
439 /*****************************************************************************
441 * helper memory allocation functions:
443 ****************************************************************************/
445 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
446 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
448 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
449 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
454 /*****************************************************************************
458 ****************************************************************************/
460 #ifdef BOOST_REGEX_CONFIG_INFO
461 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
464 #if defined(BOOST_REGEX_DIAG)
465 # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
466 # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
467 # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
468 #ifdef BOOST_REGEX_USE_C_LOCALE
469 # pragma message ("Using C locale in regex traits class")
470 #elif BOOST_REGEX_USE_CPP_LOCALE
471 # pragma message ("Using C++ locale in regex traits class")
473 # pragma message ("Using Win32 locale in regex traits class")
475 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
476 # pragma message ("Dynamic linking enabled")
478 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
479 # pragma message ("Auto-linking disabled")
481 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
482 # pragma message ("Extern templates disabled")