Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2002-03-03 07:05:24


Harold, thanks for the info, wrt:
      

---------------------------------------------------------------------------
-----

Building the Boost regex library with C++Builder 6
Introduction
Boost is a popular set of open source libraries that many C++ developers
have added to their toolset. One of the most useful libraries in Boost is
the regular expression library by Dr. John Maddock. The current version of
boost (1.27 at the time of this writing), includes makefiles for building
the regex library with BCB5 and the free BC55 command line compiler.
However, Boost does not yet include a makefile for building the regex
library with BCB6.

The lack of a makefile isn't a huge issue. However, if you try to build the
Boost regex library, you may run into additional problems. Some of those
problems have to do with the fact that Borland has switched to STLPort in
C++Builder6. The switch to STLPort is a welcome change. However, the
maintainers of Boost have not yet taken this switch into account. As a
result, some of the Boost libraries, including the regex library, fail to
compile as is with BCB6.

Thankfully, Boost is an open source library. While the regex library in
Boost 1.27 does not compile with BCB6 as is, the changes necessary to make
it compile are relatively minor. This article describes what files you need
to change in order to build Boost regex with BCB6. You can download the
patched boost files from the link at the bottom of the article.

Summary of problems
Problem 1:
---------------------
Boost does not include a BCB6 makefile for building the regex library.

Solution:
---------------------
Use the provided BCB5 makefile as a starting point.

Problem 2:
---------------------
The file boost\regex\config.hpp generates compiler errors when building
the regex library. The errors are :

Borland C++ 5.6 for Win32 Copyright (c) 1993, 2002 Borland
../src/c_regex_traits.cpp:
Error E2272 ../../../boost/regex/config.hpp 481: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 483: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 484: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 497: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 521: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 522: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 523: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 524: Identifier expected
Error E2272 ../../../boost/regex/config.hpp 525: Identifier expected
*** 9 errors in Compile ***

Solution:
---------------------
The errors were caused because BOOST_NO_STDC_NAMESPACE was defined by
boost\config\stdlib\stlport.hpp. The solution was to modify stlport.hpp to
detect the presence of BCB6. If BCB6 is detected, BOOST_NO_STDC_NAMESPACE
is not
defined.
/***** Original code- boost\config\stdlib\stlport.hpp line 78 *****/
//
// STLport does a good job of importing names into namespace std::,
// but doesn't always get them all, define BOOST_NO_STDC_NAMESPACE, since
our
// workaround does not conflict with STLports:
//
#if defined(__STL_IMPORT_VENDOR_CSTD) || defined(__STL_USE_OWN_NAMESPACE)
|| \
    defined(_STLP_IMPORT_VENDOR_CSTD) || defined(_STLP_USE_OWN_NAMESPACE)
# define BOOST_NO_STDC_NAMESPACE
#endif

/***** New code *****/
//
// STLport does a good job of importing names into namespace std::,
// but doesn't always get them all, define BOOST_NO_STDC_NAMESPACE, since
our
// workaround does not conflict with STLports:
//
// HJH note:
// Borland switched to STLport in BCB6. Defining BOOST_NO_STDC_NAMESPACE
with
// BCB6 does cause problems. If we detect BCB6, then don't define
// BOOST_NO_STDC_NAMESPACE
#if !defined(__BORLANDC__) || (__BORLANDC__ < 0x560)
#if defined(__STL_IMPORT_VENDOR_CSTD) || defined(__STL_USE_OWN_NAMESPACE)
|| \
    defined(_STLP_IMPORT_VENDOR_CSTD) || defined(_STLP_USE_OWN_NAMESPACE)
# define BOOST_NO_STDC_NAMESPACE
#endif
#endif

Problem 3:
---------------------
regex\config.hpp does not define BOOST_REGEX_USE_VCL for console mode apps
that
use the VCL. This is an existing problem that BCB5 users might want to
address.

Solution:
---------------------
Modified regex\config.hpp so that BOOST_REGEX_USE_VCL will be defined for
console mode VCL programs.
/***** Original code- boost\regex\config.hpp line 214 *****/
   //
   // VCL support:
   // if we're building a console app then there can't be any VCL (can
there?)
   //
# if !defined(__CONSOLE__) && !defined(_NO_VCL)
# define BOOST_REGEX_USE_VCL
# endif

/***** New code *****/
   //
   // VCL support:
   // if we're building a console app then there can't be any VCL (can
there?)
   //
   // HJH note:
   // Changed this to support VCL console mode apps. VCL apps and console
mode
   // apps are not exclusive features. It is possible, and quite handy, to
   // create console mode apps that use the VCL. This line originally was
   // written as this: # if !defined(__CONSOLE__) && !defined(_NO_VCL)
   // I have removed the __CONSOLE__ part.
   //
# if !defined(_NO_VCL)
# define BOOST_REGEX_USE_VCL
# endif

---------------------------------------------------------------------------
-----

There is a potential problem here: the free bcb compiler (and the command
line tools in general) do not define _NO_VCL - in fact there is no way to
tell (as far as I can see) whether we have -tWV set on the command line or
not, unless we rely on the IDE generated _NO_VCL flag. One problem with
your fix as above is that users of the command line tools will not be able
to build boost.regex as is (they'll get errors from missing libs). Anyway
that's why I disabled VCL support for console apps. But there is no really
good solution as far as I can see. Any ideas much appreciated...

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk