[Rcpp-devel] Question regarding integrating preexisting C++ code via Rcpp
Dirk Eddelbuettel
edd at debian.org
Wed Oct 12 16:32:20 CEST 2011
On 12 October 2011 at 14:51, Simon Fuller wrote:
| Hello,
|
| We cross-posted. Yes, you're right. I misunderstood the use of includes -
And had you posted reproducible examples we could have told you that days
ago.
Have a look at the recent post by Whit Armstrong about his updated CppBugs
example -- that does just that: mix with other classes.
Dirk
| 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
|
|
|
| ----------------------------------------------------------------------
| _______________________________________________
| 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
--
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
More information about the Rcpp-devel
mailing list