Rcpp::interfaces attribute is added to a C++ source file to specify which languages to generate bindings for from exported functions. For example:
// [[Rcpp::interfaces(r, cpp)]]r and cpp, and more than one interface can be specified.Rcpp::interfaces attribute is used to determine which bindings to generate for exported functions. The default behavior if no Rcpp::interfaces attribute is specified is to generate only an R interface.
When cpp bindings are requested code is generated as follows:inst/includedirectory of the package using the naming conventionPackageName_RcppExports.hR_RegisterCCallableandR_GetCCallablefunctions).foo could be called from package MyPackage as follows:// [[Rcpp::depends(MyPackage)]]
#include
void foo() { MyPackage::bar(); }
The above example assumes that the sourceCpp function will be used to compile the code. If rather than that you are building a package then you don't need to include the Rcpp::depends attribute, but instead should add an entry for the referenced package in the Depends and LinkingTo fields of your package's DESCRIPTION file.
compileAttributes, Rcpp::export, Rcpp::depends// [[Rcpp::interfaces(r, cpp)]]Run the code above in your browser using DataLab