[Rcpp-devel] rcpp 0.10 on mac error with sourceCpp
Dirk Eddelbuettel
edd at debian.org
Thu Nov 15 19:52:04 CET 2012
On 15 November 2012 at 13:40, Jiqiang Guo wrote:
| Thanks.
|
| The same error if I use cppFunction thought the example in sourceCpp
| use a string of c++ code passed using code:
Oh, sorry, my bad -- was short of time and couldn;t test, and don't even have
a mac. I will let the mac squad get to it...
Dirk
| > require(Rcpp)
| >
| > cppFunction(code='
| + #include <Rcpp.h>
| +
| + // [[Rcpp::export]]
| + int fibonacci(const int x) {
| + if (x == 0) return(0);
| + if (x == 1) return(1);
| + return (fibonacci(x - 1)) + fibonacci(x - 2);
| + }'
| + )
| Error in tools:::file_path_as_absolute(base:::system.file(..., package
| = "Rcpp")) :
| file '' does not exist
| >
| >
| > ?cppFunction
| > example(sourceCpp)
|
| srcCpp> ## Not run:
| srcCpp> ##D
| srcCpp> ##D sourceCpp("fibonacci.cpp")
| srcCpp> ##D
| srcCpp> ##D sourceCpp(code='
| srcCpp> ##D #include <Rcpp.h>
| srcCpp> ##D
| srcCpp> ##D // [[Rcpp::export]]
| srcCpp> ##D int fibonacci(const int x) {
| srcCpp> ##D if (x == 0) return(0);
| srcCpp> ##D if (x == 1) return(1);
| srcCpp> ##D return (fibonacci(x - 1)) + fibonacci(x - 2);
| srcCpp> ##D }'
| srcCpp> ##D )
| srcCpp> ##D
| srcCpp> ## End(Not run)
| srcCpp>
| srcCpp>
| srcCpp>
|
|
| --
| Jiqiang
|
| On Thu, Nov 15, 2012 at 1:34 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
| > On 15 November 2012 at 13:20, Jiqiang Guo wrote:
| > | I tried the example of sourceCpp on Mac mountain lion with R 2.15.1
| > | with the following error (I hit the similar error in using RStan as
| > | well).
| > |
| > | > library(Rcpp)
| > | > require(Rcpp)
| > | >
| > | > sourceCpp(code='
| >
| > Operator error: sourceCpp() takes a filename. cppFunction() takes a
| > "program in a string" a la cxxfunction()
| >
| > Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list