reprex:
nc <- nClass(
Cpublic = list(
x = 'numericVector'
)
)
nf <- nFunction(
function(obj = 'nc') {
}
)
comp <- nCompile(nc, nf, package = TRUE) # FAILS
comp$nf(comp$nc$new())
The problem is that RcppExports.cpp needs to see the header file for the nc nClass (which would be nClass_1_ or such), because std::shared_ptr<nClass_1_> appears in the code Rcpp::compileAttributes creates in RcppExports.cpp for nf. We have test coverage of passing nClasses as arguments, but evidently either that happens only for nClass methods (in which case only the new_<type> function for the class is in RcppExports.cpp) or the package=TRUE pathway is not used (in which case nCompile succeeds).
A possible solution would be to generate a standard all.h that can be included simply in RcppExports.cpp and that includes all generated headers.
reprex:
The problem is that
RcppExports.cppneeds to see the header file for thencnClass (which would benClass_1_or such), becausestd::shared_ptr<nClass_1_>appears in the codeRcpp::compileAttributescreates inRcppExports.cppfornf. We have test coverage of passing nClasses as arguments, but evidently either that happens only for nClass methods (in which case only thenew_<type>function for the class is inRcppExports.cpp) or thepackage=TRUEpathway is not used (in which casenCompilesucceeds).A possible solution would be to generate a standard
all.hthat can be included simply in RcppExports.cpp and that includes all generated headers.