问题
How to use RCPP_MODULE(yada) in C++. My C++ program gives error if I use
const char* hello( std::string who ){
std::string result( "hello " ) ;
result += who ;
return result.c_str() ;
}
RCPP_MODULE(yada)
{
using namespace std;
function( "hello", &hello ) ;
};
Error are:
1. Error 1 error C2065: 'yada' : undeclared identifier
2. Error 2 error C2448: 'RCPP_MODULE' : function-style initializer appears to be a function definition
Can anyone help me in fixing these error?
回答1:
Rcpp does not work with Visual Studio, see Question 2.7 in Rcpp FAQ.
回答2:
The point of RCPP_MODULE is to expose C++ to R.
You need to include R.h and Rdefines.h and state using namespace Rcpp;
来源:https://stackoverflow.com/questions/3281737/r-c-interface