R/C++ Interface

徘徊边缘 提交于 2019-12-25 18:26:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!