I have a c++ function called add
defined in file add.cpp (content of add.cpp below):
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double add(double a, double b) {
return a + b;
}
I have another c++ function called multiplyandadd
defined in multiplyandadd.cpp file (content of multiplyandadd.cpp below) that calls add
function from above:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double multiplyandadd(double a, double b, double c) {
return c*add(a, b);
}
In order for this to work I figured out I should create a header file add.h in sub folder /inst/include of my package and define function add
in add.h...
What should the content of add.h be? How to define this function add
in add.h so that the package compiles?
I am sure this is very basic and probably answered many times before and very well documented with tons of examples... It just happens I was not able to find an example in a couple of hours reading docs, stackoverflow answers, ...