This bugzilla service is closed. All entries have been migrated to
Bug 1720 - Eigen leaves macro I defined
Summary: Eigen leaves macro I defined
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.3 (current stable)
Hardware: All Linux
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2019-05-31 11:41 UTC by Djordje Zivanovic
Modified: 2019-12-04 18:40 UTC (History)
3 users (show)


Description Djordje Zivanovic 2019-05-31 11:41:46 UTC
I have tried using LAPACK + BLAS + Eigen following the instructions . 
However, when I define EIGEN_USE_BLAS and EIGEN_USE_LAPACKE and have the following order in the first header file:

#include <boost/thread/barrier.hpp>
#include <Eigen/Dense>

the following compilation error appears:

In file included from /usr/include/c++/7/complex.h:36:0,
                 from /usr/local/include/Eigen/src/misc/lapacke.h:79,
                 from /usr/local/include/Eigen/LU:34,
                 from /usr/local/include/Eigen/Dense:2,
                 from xxx.h:4,
                 from xxx.cpp:5:

/usr/local/include/boost/type_traits/integral_constant.hpp:34:20: error: expected identifier before ‘(’ token
    template <class I, I val> struct integral_c;
/usr/local/include/boost/type_traits/integral_constant.hpp:34:20: error: expected ‘)’ before ‘__extension__’
    template <class I, I val> struct integral_c;
/usr/local/include/boost/type_traits/integral_constant.hpp:34:20: error: expected ‘>’ before ‘__extension__’
/usr/local/include/boost/type_traits/integral_constant.hpp:34:20: error: expected unqualified-id before ‘)’ token
    template <class I, I val> struct integral_c;

I tracked the origin of this compiler error and it is from 
#include <complex.h> that defines I. (

I successfully circumvent the problem by adding #undef I after #include<Eigen/Dense>, but you should solve this problem for future releases of Eigen.
Comment 1 Christoph Hertzberg 2019-05-31 14:58:33 UTC
This seems to be rather a problem with `complex.h` and boost. AFAIK, Eigen itself completely avoids using `I` as an identifier.

OTOH, we probably don't break much, if we `#undef I`. Another (probably better) approach could be to add this before including lapacke.h (thus avoiding to include "complex.h"):

#ifndef lapack_complex_float
#define lapack_complex_float std::complex<float>
#ifndef lapack_complex_double 
#define lapack_complex_double std::complex<double>
Comment 2 Gael Guennebaud 2019-06-04 14:31:21 UTC
Defining lapack_complex_* seems to be fine, at leat for my setup.
Comment 3 Christoph Hertzberg 2019-06-05 08:42:38 UTC
Can we just modify lapacke.h? (It looks like something auto-generated by MKL)
Otherwise, we need to wrap this by another small header.
Comment 4 Nobody 2019-12-04 18:40:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.