[Rcpp-devel] Question regarding integrating preexisting C++ code via Rcpp

Simon Fuller simonfuller9 at gmail.com
Wed Oct 12 15:51:44 CEST 2011


Hello,

We cross-posted. Yes, you're right. I misunderstood the use of includes -
global -  that is a good way of thinking about it.

Thanks for everything.

Simon

On Wed, Oct 12, 2011 at 2:06 PM, Darren Cook <darren at dcook.org> wrote:

> > 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)
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20111012/8e0d20ca/attachment.htm>


More information about the Rcpp-devel mailing list