Boost logo

Boost :

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


$ 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
                  from /usr/local/include/boost_1_32_0/boost/regex.hpp:34,
/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

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

# 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


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 :
Programming    :

Boost list run by bdawes at, gregod at, cpdaniel at, john at