[Rcpp-devel] Header-only version of Rcpp provides a couple of gotcha's in RcppEigen

Romain Francois romain at r-enthusiasts.com
Thu Nov 14 22:39:02 CET 2013


Le 14/11/2013 21:34, Douglas Bates a écrit :
> If I install the latest, header-only, git version of Rcpp (f117a70),
> which is a great achievement by the way,

Thanks.

> installation of RcppEigen
> encounters a few minor problems.  One seems to be related to conflicting
> definitions of trunc in Rmath.h and in fstream

Likely undoRmath is done too late. This is an Rcpp problem. Many files 
have moved around as part of making Rcpp header only

> In file included from fastLm.cpp:23:
> In file included from ./fastLm.h:25:
> In file included from ../inst/include/RcppEigen.h:25:
> In file included from ../inst/include/RcppEigenForward.h:39:
> In file included from ../inst/include/unsupported/Eigen/SparseExtra:22:
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/fstream:641:60:
> error: no member named 'Rf_ftrunc' in 'std::ios_base'
> In file included from                      ios_base::openmode __mode =
> ios_base::out|ios_base::trunc)
>                                                                 ~~~~~~~~~~^
> RcppEigen.cpp:22:
> In file included from ../inst/include/RcppEigen.h:25:
> /home/bates/build/R-devel/include/Rmath.h:In file included from
> ../inst/include/RcppEigenForward.h348::3915::
> In file included from  note:
> ../inst/include/unsupported/Eigen/SparseExtra:expanded 22:
> from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/fstreammacro
> :641'trunc'
> :60: error: #define trunc   ftrunc
> no                 ^
> member /home/bates/build/R-devel/include/Rmath.hnamed :247'Rf_ftrunc'
> :17in : 'std::ios_base'
> note: expanded from macro 'ftrunc'
> #define ftrunc          Rf_ftrunc
>                          ^
>                       ios_base::openmode __mode =
> ios_base::out|ios_base::trunc)
>
> The other looks like I was playing a bit fast and loose with converting
> an attribute to a list
>
> make: *** Waiting for unfinished jobs....
> fastLm.cpp:217:20: error: call to constructor of 'List' (aka
> 'Vector<19>') is ambiguous
>              List          dimnames(NumericMatrix(Xs).attr("dimnames"));
>                            ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not yet sure how to resolve this ambiguity which occupied me this 
morning. This instead should work fine:

List dimnames = NumericMatrix(Xs).attr("dimnames");

> There is one more problem, but I think that needs a namespace qualifier.
>
> fastLm.cpp:240:6: error: use of undeclared identifier
> 'forward_exception_to_r'; did you mean 'Rcpp::forward_exception_to_r'?
>              forward_exception_to_r( ex );
>              ^~~~~~~~~~~~~~~~~~~~~~
>              Rcpp::forward_exception_to_r
> /home/bates/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include/Rcpp/exceptions.h:172:17:
> note: 'Rcpp::forward_exception_to_r' declared here
>      inline void forward_exception_to_r( const std::exception& ex){
>                  ^

Ah. I probably moved it to the Rcpp:: namespace, these are usually 
called through the BEGIN_RCPP / END_RCPP or nowadays by compileAttributes.

> Do these all look like issues that I should address in RcppEigen?

This seems more like Rcpp issues. However I'll propose a few changes to 
RcppEigen so that it uses attributes. I'll make a branch and send a pull 
request so that you can validate it.

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30



More information about the Rcpp-devel mailing list