1
我是Rcpp的初學者。 我可以問一個非常基本的問題嗎?下面是簡單的代碼:Rcpp:如何在函數中設置字符參數?
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int test(char d) {
char c;
c=d;
return 0;
}
但是當我嘗試編譯它,我總是得到這樣的錯誤:
/usr/local/genomics/programs/R-3.0.0/library/Rcpp/include/Rcpp/as.h: In function ‘T Rcpp::internal::as_string(SEXPREC*, Rcpp::traits::false_type) [with T = char]’:
/usr/local/genomics/programs/R-3.0.0/library/Rcpp/include/Rcpp/as.h:66: instantiated from ‘T Rcpp::internal::as(SEXPREC*, Rcpp::traits::r_type_string_tag) [with T = char]’
/usr/local/genomics/programs/R-3.0.0/library/Rcpp/include/Rcpp/as.h:126: instantiated from ‘T Rcpp::as(SEXPREC*) [with T = char]’
test1.cpp:18: instantiated from here
/usr/local/genomics/programs/R-3.0.0/library/Rcpp/include/Rcpp/as.h:62: error: invalid conversion from ‘const char*’ to ‘char’
make: *** [test1.o] Error 1
g++ -I/usr/local/genomics/programs/R-3.0.0/include -DNDEBUG -I/usr/local/include -I"/usr/local/genomics/programs/R-3.0.0/library/Rcpp/include" -fpic -g -O2 -c test1.cpp -o test1.o
錯誤sourceCpp( 「test1.cpp」): 錯誤1發生建設共享庫。
你能告訴我會發生什麼嗎?非常感謝你!
非常感謝! – user2380245 2013-05-15 00:52:42
然而,它是一個'錯誤',所以我們登錄並會看看我們是否可以修復。不像我指出的那樣非常重要。通過選擇'tickmark'可以自由地'接受'答案。 – 2013-05-15 00:55:16