Boost logo

Boost :

From: Maciej Sobczak (prog_at_[hidden])
Date: 2004-11-28 16:49:07


Hi,

$ g++ --version
g++ (GCC) 3.4.2 [FreeBSD] 20040728

(boost version 1.32)

When compiling a very simple example for the regex library, I've got the
following error:

In file included from
/usr/local/include/boost_1_32_0/boost/regex/v4/regex.hpp:99,
                  from /usr/local/include/boost_1_32_0/boost/regex.hpp:34,
                  from regex.cc:1:
/usr/local/include/boost_1_32_0/boost/regex/v4/instances.hpp:71: error:
ISO C++ forbids the use of `extern' on explicit instantiations
*** Error code 1

A short investigation points to the following code in the instances.hpp
file:

#elif (defined(BOOST_MSVC) && defined(_MSC_EXTENSIONS)) || defined(__GNUC__)

# ifndef BOOST_REGEX_INSTANTIATE
# define template extern template // (*)
# endif

# ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251 4231 4660)
# endif

template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >;

IMHO (and rather guessing), the #define in (*) is performed
unnecessarily for g++ 3.4.2, but is executed just because of too generic
__GNUC__ a little bit higher.

As a temporary solution, I have just uncommented the following line in
boost/regex/user.hpp:

#define BOOST_REGEX_NO_EXTERNAL_TEMPLATES

Now the simple program compiles and works fine. What influence will the
above change in user.hpp have on bigger programs?

Is this a known problem?

-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/

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