[Rcpp-devel] Extending Rcpp::wrap from the Extending Rcpp vignette

Douglas Bates bates at stat.wisc.edu
Sun Jun 20 18:27:35 CEST 2010


I'm confused about where the Rcpp.h file is included when using
"intrusive" extension of Rcpp::wrap as described in section 2.1 of the
vignette "Extending Rcpp".

I would like to define the SEXP operator for the C++ classes
corresponding to the Matrix package S4 classes.  These are declared in
lme4a/src/MatrixNs.h

It appears to me from the vignette that I need to include RcppCommon.h
then declare my classes and the operator member SEXP() then include
Rcpp.h

The problem is that my classes have members that are declared through
Rcpp.h, so, for example, I need declarations of Rcpp::List,
Rcpp::NumericVector, etc. to be able to declare my classes.

If it is the case that I must declare my classes and their operator
SEXP() member before including Rcpp.h, should I use forward
declarations of the various Rcpp classes that are used in my classes?

I hope the question is clear.  If not, I will provide sample code.

This template stuff is very powerful but very confusing.


More information about the Rcpp-devel mailing list