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>
29 /*****************************************************************************
31 * Include all the headers we need here:
33 ****************************************************************************/
37 # ifndef BOOST_REGEX_USER_CONFIG
38 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
41 # include BOOST_REGEX_USER_CONFIG
43 # include <boost/config.hpp>
48 * don't include <boost/config.hpp> because that may
49 * do C++ specific things in future...
54 # define BOOST_MSVC _MSC_VER
58 /*****************************************************************************
60 * Boilerplate regex config options:
62 ****************************************************************************/
64 /* Obsolete macro, use BOOST_VERSION instead: */
65 #define BOOST_RE_VERSION 320
68 #if defined(_UNICODE) && !defined(UNICODE)
73 * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
74 * masks to be combined, for example:
75 * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
79 # define BOOST_REGEX_BUGGY_CTYPE_FACET
83 * Intel C++ before 8.0 ends up with unresolved externals unless we turn off
84 * extern template support:
86 #if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
87 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
90 * Visual C++ doesn't support external templates with C++ extensions turned off:
92 #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
93 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
96 * Shared regex lib will crash without this, frankly it looks a lot like a gcc bug:
98 #if defined(__MINGW32__)
99 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
103 * If there isn't good enough wide character support then there will
104 * be no wide character regular expressions:
106 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
107 # if !defined(BOOST_NO_WREGEX)
108 # define BOOST_NO_WREGEX
111 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
112 /* STLPort on IRIX is misconfigured: <cwctype> does not compile
113 * as a temporary fix include <wctype.h> instead and prevent inclusion
114 * of STLPort version of <cwctype> */
116 # define __STLPORT_CWCTYPE
117 # define _STLP_CWCTYPE
121 # include <boost/regex/config/cwchar.hpp>
127 * If Win32 support has been disabled for boost in general, then
128 * it is for regex in particular:
130 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
131 # define BOOST_REGEX_NO_W32
134 /* disable our own file-iterators and mapfiles if we can't
136 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
137 # define BOOST_REGEX_NO_FILEITER
140 /* backwards compatibitity: */
141 #if defined(BOOST_RE_NO_LIB)
142 # define BOOST_REGEX_NO_LIB
145 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
146 /* gcc on win32 has problems if you include <windows.h>
147 (sporadically generates bad code). */
148 # define BOOST_REGEX_NO_W32
150 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
151 # define BOOST_REGEX_NO_W32
154 /*****************************************************************************
156 * Wide character workarounds:
158 ****************************************************************************/
161 * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
162 * code may be built with wchar_t as unsigned short: basically when we're building
163 * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
164 * of the non-inline functions in the library, so that users can still link to the lib,
165 * irrespective of whether their own code is built with /Zc:wchar_t.
166 * Note that this does NOT WORK with VC10 when the C++ locale is in effect as
167 * the locale's <unsigned short> facets simply do not compile in that case.
169 #if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) && ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE))
170 # define BOOST_REGEX_HAS_OTHER_WCHAR_T
172 # pragma warning(push)
173 # pragma warning(disable : 4251 4231)
174 # if BOOST_MSVC < 1600
175 # pragma warning(disable : 4660)
178 # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
180 extern template class __declspec(dllimport) std::basic_string<unsigned short>;
183 # pragma warning(pop)
188 /*****************************************************************************
190 * Set up dll import/export options:
192 ****************************************************************************/
194 #ifndef BOOST_SYMBOL_EXPORT
195 # define BOOST_SYMBOL_EXPORT
196 # define BOOST_SYMBOL_IMPORT
199 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
200 # if defined(BOOST_REGEX_SOURCE)
201 # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
202 # define BOOST_REGEX_BUILD_DLL
204 # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
207 # define BOOST_REGEX_DECL
210 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
211 # define BOOST_LIB_NAME boost_regex
212 # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
213 # define BOOST_DYN_LINK
215 # ifdef BOOST_REGEX_DIAG
216 # define BOOST_LIB_DIAGNOSTIC
218 # include <boost/config/auto_link.hpp>
221 /*****************************************************************************
223 * Set up function call type:
225 ****************************************************************************/
227 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
228 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
229 # define BOOST_REGEX_CALL __cdecl
231 # define BOOST_REGEX_CALL __fastcall
233 # define BOOST_REGEX_CCALL __cdecl
236 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
237 # define BOOST_REGEX_CALL __fastcall
238 # define BOOST_REGEX_CCALL __stdcall
241 #ifndef BOOST_REGEX_CALL
242 # define BOOST_REGEX_CALL
244 #ifndef BOOST_REGEX_CCALL
245 #define BOOST_REGEX_CCALL
248 /*****************************************************************************
250 * Set up localisation model:
252 ****************************************************************************/
254 /* backwards compatibility: */
255 #ifdef BOOST_RE_LOCALE_C
256 # define BOOST_REGEX_USE_C_LOCALE
259 #ifdef BOOST_RE_LOCALE_CPP
260 # define BOOST_REGEX_USE_CPP_LOCALE
263 #if defined(__CYGWIN__)
264 # define BOOST_REGEX_USE_C_LOCALE
267 /* Win32 defaults to native Win32 locale: */
268 #if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32)
269 # define BOOST_REGEX_USE_WIN32_LOCALE
271 /* otherwise use C++ locale if supported: */
272 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
273 # define BOOST_REGEX_USE_CPP_LOCALE
275 /* otherwise use C+ locale: */
276 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
277 # define BOOST_REGEX_USE_C_LOCALE
280 #ifndef BOOST_REGEX_MAX_STATE_COUNT
281 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
285 /*****************************************************************************
287 * Error Handling for exception free compilers:
289 ****************************************************************************/
291 #ifdef BOOST_NO_EXCEPTIONS
293 * If there are no exceptions then we must report critical-errors
294 * the only way we know how; by terminating.
298 #include <boost/throw_exception.hpp>
300 # define BOOST_REGEX_NOEH_ASSERT(x)\
303 std::string s("Error: critical regex++ failure in: ");\
305 std::runtime_error e(s);\
306 boost::throw_exception(e);\
310 * With exceptions then error handling is taken care of and
311 * there is no need for these checks:
313 # define BOOST_REGEX_NOEH_ASSERT(x)
317 /*****************************************************************************
319 * Stack protection under MS Windows:
321 ****************************************************************************/
323 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
324 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
325 && !defined(__GNUC__) \
326 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
327 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
328 # define BOOST_REGEX_HAS_MS_STACK_GUARD
330 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
331 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
334 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
339 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
347 /*****************************************************************************
349 * Algorithm selection and configuration:
351 ****************************************************************************/
353 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
354 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400))
355 # define BOOST_REGEX_RECURSIVE
357 # define BOOST_REGEX_NON_RECURSIVE
361 #ifdef BOOST_REGEX_NON_RECURSIVE
362 # ifdef BOOST_REGEX_RECURSIVE
363 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
365 # ifndef BOOST_REGEX_BLOCKSIZE
366 # define BOOST_REGEX_BLOCKSIZE 4096
368 # if BOOST_REGEX_BLOCKSIZE < 512
369 # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
371 # ifndef BOOST_REGEX_MAX_BLOCKS
372 # define BOOST_REGEX_MAX_BLOCKS 1024
374 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
375 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
377 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
378 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
383 /*****************************************************************************
385 * helper memory allocation functions:
387 ****************************************************************************/
389 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
390 namespace boost{ namespace re_detail{
392 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
393 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
398 /*****************************************************************************
402 ****************************************************************************/
404 #ifdef BOOST_REGEX_CONFIG_INFO
405 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
408 #if defined(BOOST_REGEX_DIAG)
409 # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
410 # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
411 # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
412 #ifdef BOOST_REGEX_USE_C_LOCALE
413 # pragma message ("Using C locale in regex traits class")
414 #elif BOOST_REGEX_USE_CPP_LOCALE
415 # pragma message ("Using C++ locale in regex traits class")
417 # pragma message ("Using Win32 locale in regex traits class")
419 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
420 # pragma message ("Dynamic linking enabled")
422 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
423 # pragma message ("Auto-linking disabled")
425 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
426 # pragma message ("Extern templates disabled")