0

I can run some example code from inline::cxxfunction()'s documentation:

inline::cxxfunction(signature(x = "integer", y = "numeric"), 
            "return wrap( as<int>(x) * as<double>(y));",
            plugin = "Rcpp" )

and that works, but the minute I try to use my plugin,

inline::cxxfunction(signature(x = "integer", y = "numeric"), 
                    "return wrap( as<int>(x) * as<double>(y));",
                    plugin = "pfr" )

it doesn't. I get the error

Error in compileCode(f, code, language = language, verbose = verbose) : 
  file59cc7af8325c.cpp:11:1: error: ‘SEXP’ does not name a type   11 | SEXP file59cc7af8325c( SEXP x, SEXP y) ;      | ^~~~file59cc7af8325c.cpp:15:1: error: ‘SEXP’ does not name a type   15 | SEXP file59cc7af8325c(SEXP x, SEXP y) {      | ^~~~make: *** [/usr/lib/R/etc/Makeconf:177: file59cc7af8325c.o] Error 1

Here's my plugin's output:

$includes
[1] "// [[Rcpp::plugins(cpp14)]]\n"

$body
function(x) x
<bytecode: 0x5601b7f4bb88>
<environment: 0x5601bb0a5140>

$env
$env$PKG_CPPFLAGS
[1] "  -I\"/home/trb5me_admin/pfr/inst/include/\"  -I\"/home/trb5me_admin/R/x86_64-pc-linux-gnu-library/4.2/Rcpp/include/\"  -I\"/home/trb5me_admin/R/x86_64-pc-linux-gnu-library/4.2/RcppEigen/include/\"  -I\"/home/trb5me_admin/R/x86_64-pc-linux-gnu-library/4.2/RcppEigen/include/unsupported\"  -DEIGEN_NO_DEBUG  -DDROPPINGTHISINRPACKAGE "


$LinkingTo
[1] "RcppEigen" "Rcpp"     

$Depends
[1] "RcppEigen" "Rcpp"     

$Imports
[1] "RcppEigen" "Rcpp"
Taylor
  • 1,797
  • 4
  • 26
  • 51
  • 1
    Have you seen the API helper `Rcpp::Rcpp.plugin.maker`? You don't include `Rcpp.h`, so you don't include `Rinternals.h`, so you don't define `SEXP`. – Mikael Jagan Jul 11 '23 at 19:43
  • @MikaelJagan yes I have, but I was modeling my plugin after one that doesn't use it. I think the error goes away if you throw in some stuff to `includes=` – Taylor Jul 11 '23 at 20:04
  • 1
    Failing to include `Rcpp.h` is just one problem. AFAIK, **Rcpp** attributes in `includes` are not processed specially. To compile with `-std=c++14`, you need to model your plugin after `Rcpp:::.findPlugin("cpp14")`. – Mikael Jagan Jul 11 '23 at 20:39

0 Answers0