[Rcpp-devel] ‘_’ was not declared in this scope

Vincent Arel vincent.arel at gmail.com
Sun May 29 20:45:26 CEST 2011

Hi all,

Apologies for the newbie question, but I am trying to build my first R
package with a Rcpp function, and I am running into some issues with
Sugar expressions not compiling. I tried to model my package on one of
the RcppExamples, and put the code pasted below in the file
/src/ar1.cpp. There's also an R function in /R/ar1.R with a simple
.Call to the c++ function. I build the package, but when I try to
install it from source using 'R CMD INSTALL mypackage.tar.gz', I get
the error pasted below. But the example works fine with the inline

I am running R 2.12 on Ubuntu 11.04.

Thanks for your time!


### Error:

ar1.cpp: In function ‘SEXPREC* ar1(SEXPREC*, SEXPREC*)’:
ar1.cpp:8:11: error: ‘_’ was not declared in this scope
make: *** [ar1.o] Error 1
ERROR: compilation failed for package ‘mypackage’

### Code:

#include "Rcpp.h"

RcppExport SEXP ar1(SEXP xbe, SEXP g){
     Rcpp::NumericMatrix xbem(xbe);
     int nrows = xbem.nrow();
     Rcpp::NumericVector gv(g);
     for (int i = 1; i < nrows; i++) {
	  xbem(i,_) = xbem(i-1,_) * gv[0] + xbem(i,_);
     return xbem;

More information about the Rcpp-devel mailing list