[Rcpp-devel] inline error

Hadley Wickham h.wickham at gmail.com
Tue Oct 29 18:00:23 CET 2013


Oops, so this would be better:

library(Rcpp)
cppFunction("int x(NumericVector start) {
  return 1;
}")

Hadley

On Mon, Oct 28, 2013 at 12:29 PM, Romain Francois
<romain at r-enthusiasts.com> wrote:
> 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 <h.wickham at gmail.com> 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 <szehnder at uni-bonn.de> 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
>>> Rcpp-devel at lists.r-forge.r-project.org
>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>>
>>
>> --
>> Chief Scientist, RStudio
>> http://had.co.nz/
>> _______________________________________________
>> 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



-- 
Chief Scientist, RStudio
http://had.co.nz/


More information about the Rcpp-devel mailing list