Skip to content

Allow TMB to compile with the latest version of RcppEigen that ships Eigen v5 #417

Description

@timflutre

I have a package on CRAN depending on TMB (thanks a lot for your great package by the way), hence on RcppEigen. I have been recently contacted by A. Johnson who told me that CRAN's version of RcppEigen will soon be updated with the latest version of RcpEigen that ships the latest version of Eigen (v5), and that this will break my package: "Eigen 5 introduced a new ‘array<>’ typedef which is conflicting with the TMB ‘array<>’ typedef. To account for this, your C++ needs to be updated to specify ’tmbutils::array<>’ instead to remove the ambiguity". This was easy to fix, and everything works with CRAN's version of RcppEigen.

However, when I tested building my package against the latest RcppEigen version on GitHub's main branch, I had the following error:

/home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/tmbutils/density.hpp:22:9: error: reference to ‘array’ is ambiguous
   22 | typedef array<scalartype> arraytype
      |         ^~~~~
/home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/tmbutils/density.hpp:22:9: note: in definition of macro ‘TYPEDEFS’
   22 | typedef array<scalartype> arraytype
      |         ^~~~~
In file included from /home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/tmbutils/tmbutils.hpp:21,
                 from /home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/TMB.hpp:200:
/home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/tmbutils/array.hpp:22:8: note: candidates are: ‘template<class Type> struct tmbutils::array’
   22 | struct array:Map< Array<Type,Dynamic,1> >{
      |        ^~~~~
In file included from /home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/RcppEigen/include/Eigen/Core:194,
                 from /home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/RcppEigen/include/Eigen/Dense:1,
                 from /home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/TMB.hpp:92:
/home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/RcppEigen/include/Eigen/src/Core/util/EmulateArray.h:231:7: note:                 ‘template<class T, long unsigned int N> using array = std::array<_Tp, _Nm
’                                                                                                      
  231 | using array = std::array<T, N>;
      |       ^~~~~
/home/tflutre/lib/R/x86_64-pc-linux-gnu-library/4.5/TMB/include/tmbutils/density.hpp:173:3: error: ‘arraytype’ does not name a type
  173 |   arraytype jacobian(arraytype x){
      |   ^~~~~~~~~

Is this easy to fix on TMB's side? Thank you in advance, and sorry if you ware already contacted to do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions