[Rcpp-devel] C++ class methods exported via Interfaces Attribute?

Charles Determan cdetermanjr at gmail.com
Mon Aug 15 15:21:06 CEST 2016

Thanks JJ, this is actually the answer I was expecting but I wanted to make


On Mon, Aug 15, 2016 at 8:20 AM, JJ Allaire <jj.allaire at gmail.com> wrote:

> Rcpp attributes only work for global/free functions rather than class
> members. If you want to share clashes between packages the only good way to
> do it is header-only classes that you put in inst/include.
> On Mon, Aug 15, 2016 at 6:17 AM Charles Determan <cdetermanjr at gmail.com>
> wrote:
>> Greetings,
>> I am trying to integrate some packages of mine so they can share some of
>> the same C++ functions (not exposed to the R front-end user).  Here is my
>> basic structure of the package I wish to export functions.
>> Class defined in header (foo.h) complete with all public and private
>> members.
>> Members defined in cpp file (foo.cpp).
>> This is also where I thought I could use the Rcpp::interfaces(cpp)
>> function generate the header file automatically (as I am not aware of a
>> nice linking operation between multiple package .so files).  So each method
>> is prefixed with //[[Rcpp::export]] for the package building.
>> I liked this approach because I wouldn't have to rewrite all my methods
>> to the header file manually.  However, this doesn't appear to be working.
>> I am getting errors on the first method (I have tried only exporting one
>> method and I get the same error).
>> In file included from ../inst/include/gpuR.h:7:0,
>>                  from RcppExports.cpp:4:
>> ../inst/include/gpuR_RcppExports.h:28:20: error: expected unqualified-id
>> before ‘<’ token
>>      inline template<typename T> dynEigenMat<T>::dynEigenMat(SEXP A_) {
>>                     ^
>> RcppExports.cpp:3313:1: error: expected ‘;’ at end of input
>>  }
>>  ^
>> RcppExports.cpp:3313:1: error: expected ‘}’ at end of input
>> Any insight would be appreciated.  Not sure if it is a problem with using
>> the template methods or if this means I simply have a typo somewhere (I
>> don't think so given that the code works without using the Rcpp interfaces
>> attribute.
>> Regards,
>> Charles
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160815/fc1f3d08/attachment.html>

More information about the Rcpp-devel mailing list