[Rcpp-devel] Combining C++ interface and exported function name with dot

Ralf Stubner ralf.stubner at r-institute.com
Tue Apr 17 17:32:14 CEST 2018


Hi,

I am developing a package where I would like to combine two Rcpp
Attribute features:
* Automatically providing a C++ interface
* Renaming the exported function in R to contain a dot

My current attempts at doing so result in a run-time error. Steps to
reproduce:

* create an new package with Rcpp::Rcpp.package.skeleton()
* change src/rcpp_hello_world.cpp to rename the exported function and
create both R and C++ interfaces:

// [[Rcpp::interfaces(r, cpp)]]
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export(hello.world)]]
List rcpp_hello_world() {

    CharacterVector x = CharacterVector::create( "foo", "bar" )  ;
    NumericVector y   = NumericVector::create( 0.0, 1.0 ) ;
    List z            = List::create( x, y ) ;

    return z ;
}

* build and install the package
* reference the function from C++:

// [[Rcpp::depends(anRpackage)]]
#include <Rcpp.h>
#include <anRpackage.h>

// [[Rcpp::export]]
Rcpp::List wrapper() {
  return anRpackage::hello_world();
}
/*** R
wrapper()
*/

If I rename the function to 'hello_world', this compiles and runs fine.
If I rename the function to 'hello.world', it still compiles but fails
to run:

> wrapper()
Error in wrapper() :
  Function not exported: C++ function with signature
'List(*hello_world)()' not found in anRpackage.


Is there a way to combine these two features?

Thanks
Ralf

-- 
Ralf Stubner
Senior Software Engineer / Trainer

daqana GmbH
Dortustraße 48
14467 Potsdam

T: +49 331 23 70 81 66
F: +49 331 23 70 81 67
M: +49 162 20 91 196
Mail: ralf.stubner at daqana.com

Sitz: Potsdam
Register: AG Potsdam HRB 27966 P
Ust.-IdNr.: DE300072622
Geschäftsführer: Prof. Dr. Dr. Karl-Kuno Kunze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4008 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20180417/c926d05e/attachment.bin>


More information about the Rcpp-devel mailing list