[Rcpp-devel] sourceCpp error

Dirk Eddelbuettel edd at debian.org
Mon Apr 29 05:45:46 CEST 2013


On 28 April 2013 at 22:20, Subodh Acharya wrote:
| Hi, I am a beginner-class use of the amazing Rcpp. I am using to simulate
| finite state Markov chains. 
| Previously all the c++ function I wrote were working perfectly. I compiled all
| my functions in package and they work fine.
| 
| But now after I updated to Rcpp 0.10.3, whenever I sourceCpp, it throws a
| 'unused arguement' error.
| However when I use the all the functions to build a package, it works fine.
| 
| I think  this is a really small problem, but its beyond my knowledge of c++ 
| Any help will be greatly appreciated.
| 
| Following are simple  example codes and the error I am getting.. 
| 
| 
| 
| cppFunction('
| +   int add(int x, int y, int z) {
| +     int sum = x + y + z;
| +     return sum;
| +   }'
| + )
| Error in Rcpp:::sourceCppFunction(function(x, y, z) { : 
|   unused argument ("sourceCpp_94801_add")

Works perfectly fine here:

R> cppFunction('int add(int x, int y, int z) { int sum = x + y + z; return sum; }')
R> add(1,2,3)
[1] 6
R> 

Rcpp 0.10.3.* (current SVN, no real change from 0.10.3)

Maybe you hosed your setup, and set 'odd' compiler options...

Dirk
 
| 
| Second example code 
| 
|   #include <Rcpp.h>
| #include <iostream>
| #include <vector>
| 
| // [[Rcpp::export]]
| 
| using namespace Rcpp;
| using namespace std;
| 
|  
| int mcfunC(int oldState, NumericVector states, NumericMatrix prob_mat){
| 
| RNGScope scope;
| 
| NumericVector newState(1);
| 
| int pixel = oldState;
| 
|   Environment base("package:base");
|   Function sample = base["sample"];
|  
|  newState = sample(states, Named("size", 1), Named("prob", prob_mat(pixel,
| _)));
|   
|  int state_new = newState[0];
|   
|   return(state_new);
|   
|  }
|   
| 
|  Rcpp::sourceCpp('src/mcfunC.cpp')
| Error in Rcpp:::sourceCppFunction(function(oldState, states, prob_mat) { : 
|   unused argument ("sourceCpp_20302_mcfunC") 
|   
|   
| Thanks in advance.
| 
| 
| ----------------------------------------------------------------------
| _______________________________________________
| 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
-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list