[Rcpp-devel] Problems wrapping stl::vector<int>
Dirk Eddelbuettel
edd at debian.org
Fri Jan 3 18:50:28 CET 2014
On 3 January 2014 at 11:42, Hadley Wickham wrote:
| Another solution is to rely on Rcpp's auto-wrapping smarts:
|
| // [[Rcpp::export]]
| std::vector<int> test(){
| std::vector<int> a;
| a.push_back(1);
| a.push_back(2);
| a.push_back(3);
| return a;
| }
Nope.
R> sourceCpp("/tmp/scratchpad.cpp")
scratchpad.cpp: In function ‘Rcpp::IntegerVector test()’:
scratchpad.cpp:12:12: error: could not convert ‘a’ from ‘std::vector<int>’ to ‘Rcpp::IntegerVector {aka Rcpp::Vector<13>}’
scratchpad.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [scratchpad.o] Error 1
ccache g++-4.7 -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -Wno-unused -pedantic -c scratchpad.cpp -o scratchpad.o
Error in sourceCpp("/tmp/scratchpad.cpp") :
Error 1 occurred building shared library.
R> system("tail -4 /tmp/scratchpad.cpp")
//return wrap(a);
return a;
}
R>
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list