我想fopen在我的 cpp 函数中调用,但是,Rcpp总是抱怨“没有匹配的函数来调用‘fopen’”。所以完全复制了https://github.com/hadley/xml2/blob/9362d379e126a86091af8698a8987c51b5b230fe/src/xml2_doc.cpp 中的一些代码,但仍然有相同的错误。
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void doc_write(std::string path){
FILE* f = fopen(path.c_str(), 'r');
fclose(f);
}
Run Code Online (Sandbox Code Playgroud)
错误是:
testc.cpp:6:36: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
Run Code Online (Sandbox Code Playgroud)
有人可以给我一些提示吗?