[Rcpp-devel] RcppArmadillo and Rdefines
Dirk Eddelbuettel
edd at debian.org
Tue Feb 24 20:06:27 CET 2015
On 24 February 2015 at 12:30, Charles Determan Jr wrote:
| Greetings,
|
| I have run in to an error when compiling an R package that has the following
| headers in the only cpp file at the moment:
|
| #include <string>
| #include <iostream>
| #include <cmath>
|
| #define R_NO_REMAP
|
| #include <R.h>
| #include <Rinternals.h>
| #include <Rdefines.h>
|
| Now, I am also trying to use RcppArmadillo with:
|
| #include <RcppArmadillo.h>
| // [[Rcpp::depends(RcppArmadillo)]
|
| However, when I try and build the package, it errors out with a bunch of errors
| such as:
|
| /usr/include/c++/4.8/bits/fstream.tcc:824:60: error: macro "length" passed 4
| arguments, but takes just 1
|
| which is repeated multiple times on different lines. I haven't included the
| entire output as it is rather lengthly but could provide if it would help
| further. I tried searching for help but the closest I found was this previous
| post (http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-February/
| 005325.html) but the R_NO_REMAP hasn't helped here. I suspect something must
| be conflicted between the R headers and RcppArmadillo because it works just
| fine if I only use Rcpp.h (but I want to use RcppArmadillo). Any thoughts?
I definitely have fought this too way back when. I think we generally do the
right thing now as it no longer "spills" out of Rcpp proper.
You do have a bit of a mess here with headers:
a) you may not need all of string, iostream, cmath; I think we include some
(all?) of these. You may need just iostream
b) you do not need R.h; you probably do not need the others
c) just RcppArmadillo is good and often self-sufficient
so I would quickly restart from the inside out with just RcppArmadillo.h and
then add code paragraph by paragraph and judiciously only add the headers you
need.
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list