Just a warning that this code creates a NumericVector of length 1 initialised with 0.
1 is not a NumericVector so the compiler looks for a conversion, the one that is found is the ctor for NumericVector that takes an int. Romain Le 28 oct. 2013 à 17:05, Hadley Wickham <[email protected]> a écrit : > FYI, that's equivalent to the somewhat cleaner > > library(Rcpp) > cppFunction("NumericVector x(NumericVector start) { > return 1; > }") > > Hadley > > On Mon, Oct 28, 2013 at 8:58 AM, Simon Zehnder <[email protected]> wrote: >> Dear Rcpp::Users and Rcpp::Devels, >> >> I get a weird error when using inline and I want to know, where it comes >> from. I run the following code: >> >> library(Rcpp) >> library(inline) >> cfunc <- cxxfunction(signature(start="vector"), body = "Rcpp::NumericVector >> x(start); return 1;", plugins = "Rcpp”) >> >> And I get the following Error: >> >> Error in compileCode(f, code, language = language, verbose = verbose) : >> Compilation ERROR, function(s)/method(s) not created! file1606062c0507.cpp: >> In function ‘SEXPREC* file1606062c0507(SEXP)’: >> file1606062c0507.cpp:19:1: error: ‘Rcpp’ has not been declared >> Rcpp::NumericVector x(start); return 1; >> ^ >> file1606062c0507.cpp:19:21: error: expected ‘;’ before ‘x’ >> Rcpp::NumericVector x(start); return 1; >> ^ >> file1606062c0507.cpp:19:38: error: invalid conversion from ‘int’ to ‘SEXP’ >> [-fpermissive] >> Rcpp::NumericVector x(start); return 1; >> ^ >> make: *** [file1606062c0507.o] Error 1 >> In addition: Warning message: >> running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB >> file1606062c0507.cpp 2> file1606062c0507.cpp.err.txt' had status 1 >> >> Best >> Simon >> >> _______________________________________________ >> Rcpp-devel mailing list >> [email protected] >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel > > > > -- > Chief Scientist, RStudio > http://had.co.nz/ > _______________________________________________ > Rcpp-devel mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
