编译属性不';t将本地标头复制到RcppExports.cpp

编译属性不';t将本地标头复制到RcppExports.cpp,r,rcpp,R,Rcpp,这是我的R\u API.cpp #include "include/R_GatingSet.hpp" #include <Rcpp.h> Rcpp::List getPopCounts(Rcpp::XPtr<GatingSet> gsPtr, StringVec sampleNames, StringVec subpopulation, bool flowJo, bool isFullPath){ //do stuff } 显然,这会使编译器失败,因为它缺少定义用户

这是我的
R\u API.cpp

#include "include/R_GatingSet.hpp" 
#include <Rcpp.h>

Rcpp::List getPopCounts(Rcpp::XPtr<GatingSet> gsPtr, StringVec sampleNames, StringVec subpopulation, bool flowJo, bool isFullPath){
//do stuff
}
显然,这会使编译器失败,因为它缺少定义用户类的本地头include(
R\u GatingSet.hpp

g++ -I/home/wjiang2/R/r-devel/build/include -DNDEBUG -DROUT -Wno-deprecated -I/home/wjiang2/mylib/include/libxml2  -Ibst/ -I/usr/local/include -I"/home/wjiang2/R/r-devel/build/library/Rcpp/include"   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:9:36: error: ‘GatingSet’ was not declared in this scope

我想知道除了手动将此include添加回
RcppExports.cpp

之外,是否还有更好的解决方案,您应该能够通过使用与中的包同名的头文件来处理此问题(假设包是
flowWorkspace
):

compileAttributes
将在
RcppExports.cpp
中包含该头文件,并在其中包含其余导出机制工作所需的类的定义


编辑:您也可以尝试使用
/[[Rcpp::interfaces(r,cpp)]]
属性为您自动生成这些接口(虽然我没有这么多地使用过),但是在中讨论过——请参见3.5.1。

我记得几个月前在Rcpp devel上讨论过这一点。部分问题在于非R/非Rcpp类型(如
GatingSet
)通常不会公开,因为您没有任何(默认)转换器。宾果。这甚至可能记录在vignette中。将
c++
类定义复制到
inst/include/flowWorkspace.h
的副作用是将它们暴露给
R
包用户,这本身就很好。但是它会给代码维护带来麻烦吗?因为我们现在有两个
类定义
(另一个在
src/include/
)的副本。一个选项:使用
configure
cleanup
确保
src/include
中的当前版本复制到
inst/include
。只保留一个副本,并且像每个人一样做
PKG_CPPFLAGS=-I../inst/include
,例如。
g++ -I/home/wjiang2/R/r-devel/build/include -DNDEBUG -DROUT -Wno-deprecated -I/home/wjiang2/mylib/include/libxml2  -Ibst/ -I/usr/local/include -I"/home/wjiang2/R/r-devel/build/library/Rcpp/include"   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:9:36: error: ‘GatingSet’ was not declared in this scope
inst/include/flowWorkspace.h