【发布时间】:2014-10-08 18:03:41
【问题描述】:
我正在尝试编写一个具有可选参数的 C++/Rcpp 函数,该参数的默认值需要是长度为 1 且值为 0 的向量。以下无法正确编译:
cppFunction("std::vector<int> test(std::vector<int> out = {0}) {
return out;
}")
我收到以下错误:
cppFunction 中的错误(“std::vector 测试(std::vector out = {1}) {\n return out;\n}") : 未找到函数定义 另外:警告消息:1:没有找到 Rcpp::export 的函数 fileee5f629605d7.cpp:5 2 处的属性:在 sourceCpp(代码 = 代码,环境 = env, rebuild =rebuild, showOutput = showOutput, : 在源代码中找不到 Rcpp::export 属性或 RCPP_MODULE 声明
这样做的正确方法是什么?
【问题讨论】: