2016-04-03 73 views
0

我正在運行中的R-Studio給出下面的C++代碼RCPP錯誤:意外 '/' 中的 「/」

# include<Rcpp.h> 
using namespace Rcpp; 

// [[Rcpp::export]] 
NumericVector timesTwo(NumericVector x) { 
     return x * 2; 
    } 

/*** R 
    timesTwo(42) 

*/ 

2錯誤的類型來了:

Error: unexpected symbol in "using namespace"

Error: unexpected '/' in "/"

回答

3

你有

# include<Rcpp.h> 

所以嘗試#後除去空間產生

#include<Rcpp.h> 

如果該文件保存爲擴展名爲.cpp的文件,則RStudio將調用正確的功能:sourceCpp()