[Rcpp-devel] Question regarding integrating preexisting C++ code via Rcpp
Darren Cook
darren at dcook.org
Wed Oct 12 15:06:16 CEST 2011
> pertain to packages. So I will post the relevant code here, and the full
> output from verbose=TRUE below it:
I think the verbose output was missing from your email (?).
> linktest<-cxxfunction( signature( vec = "numeric", len = "integer" ), paste(
> readLines(
> "/home/simon/College/PackageOne/src/BZip/LinkTestWrap.cpp"),collapse = "\n"
> ) , plugin = "Rcpp",verbose=TRUE )
> ...
> 2. LinkTestWrap.cpp: Rcpp Wrapping Function (for use by inline)
> #include <Rcpp.h>
> #include <vector>
> #include "/home/simon/College/PackageOne/src/BZip/LinkTest.h"
>
> using std::vector;
>
> vector<int> input_vector( as< vector<int> >( vec ) );
> int length = as<int> ( len );
>
> int res = sumvec( input_vector );
>
> return Rcpp::wrap( res );
Does this mean you have three #include statements inside your function
body? The cxxfunction has an includes parameter where you should put
them. I think of "includes" as meaning "global stuff". So you could put
your "using std::vector" line in there too (that is just a style
difference, though).
Also, IIRC, plugin="Rcpp" implies the #include <Rcpp.h>, so you should
be able to drop that.
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
More information about the Rcpp-devel
mailing list