← Back to team overview

dolfin team mailing list archive

Re: uBlas/PETSc header collision for GCC 3.3.5

 

I sent an email to the PETsc guys about this on Monday (see below). We
need to include uBlas headers before PETSc headers, but this will be
fixed in PETSc

Garth 


Thanks Garth,

   This is just a convenience feature, which I will turn off by default.

   Matt

On 4/3/06, Garth N. Wells <g.n.wells@xxxxxxxxxx> wrote:
        Hi,
        
        I've come across a problem when including petscerror.h and Boost
        (www.boost.org) header files. It has to do with the macro
          #define _   __gierr =
        on line 262 of petscrror.h (PETSC 2.3.1, patch level 10). This
        causes an
        error when including petscrror.h before
        boost/numeric/ublas/matrix.hpp.
        Should the equality be there?
        
        It seems that strange things are happening to "=". You can see
        the 
        output from the compiler below. This might not be a PETSc
        problem, but
        given that Boost is commonly used in numerical software, I
        thought that
        you'd be interested.
        
        Garth
        
        /usr/include/boost/mpl/aux_/integral_wrapper.hpp:43: error:
        expected 
        unqualified-id before '=' token
        /usr/include/boost/mpl/aux_/integral_wrapper.hpp:85: error:
        explicit
        qualification in declaration of `mpl_::int__gierr'
        /usr/include/boost/mpl/aux_/integral_wrapper.hpp:85: error:
        template 
        declaration of 'const int mpl_::int__gierr'
        
        


On Fri, 2006-04-07 at 18:22 +0200, Johan Jansson wrote:
> Hi,
> 
> This is not a DOLFIN-specific issue, but it's good to be aware of it.
> 
> There is a collision between the uBlas and PETSc headers (perhaps the
> same symbol is declared in both) which causes errors if the headers
> are included in a certain order. This problem appears with GCC 3.3.5
> but seems to disappear with GCC 4.0+.
> 
> A simple test case demonstrating the error:
> 
> #include <petscvec.h>
> #include <boost/numeric/ublas/matrix.hpp>
> 
> int main()
> {
> 
>   return 0;
> }
> 
> gives:
> 
> g++ -I/usr/local/lib/petsc/ -I/usr/local/lib/petsc//bmake/linux-gnu -I/usr/local/lib/petsc//include -I/usr/include/mpi -c collision.cpp
> In file included from /usr/include/boost/mpl/int.hpp:20,
>                  from /usr/include/boost/mpl/lambda_fwd.hpp:23,
>                  from /usr/include/boost/mpl/aux_/na_spec.hpp:18,
>                  from /usr/include/boost/mpl/if.hpp:19,
>                  from /usr/include/boost/numeric/ublas/detail/config.hpp:28,
>                  from /usr/include/boost/numeric/ublas/exception.hpp:29,
>                  from /usr/include/boost/numeric/ublas/storage.hpp:25,
>                  from /usr/include/boost/numeric/ublas/vector.hpp:20,
>                  from /usr/include/boost/numeric/ublas/matrix.hpp:20,
>                  from collision.cpp:2:
> /usr/include/boost/mpl/aux_/integral_wrapper.hpp:43: error: parse error before
>    `=' token
> /usr/include/boost/mpl/aux_/integral_wrapper.hpp:51: error: typedef `
>    mpl_::int__gierr' is initialized (use __typeof__ instead)
> /usr/include/boost/mpl/aux_/integral_wrapper.hpp:51: error: `typedef int
>    mpl_::int__gierr' redeclared as different kind of symbol
> ...
> 
> if we reverse the order:
> 
> #include <boost/numeric/ublas/matrix.hpp>
> #include <petscvec.h>
> 
> int main()
> {
> 
>   return 0;
> }
> 
> the errors don't appear.
> 
> I can't see the cause of the errors, perhaps we should notify the
> uBlas and PETSc developers if it leads to more problems.
> 
> I've worked around the problem by making sure PETSc is included after
> uBlas (dolfin.h includes them in that order, I triggered the error by
> including dolfin/Vector.h before dolfin.h). Using GCC 4.0+ also seems
> to avoid the error.
> 
>   Johan
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev




Follow ups

References