1

I am lately trying to learn the (brilliant) Rcpp library. When I want to export some of my C++ code, afaik it is suggested to use sth like:

// [[Rcpp::interfaces(r, cpp)]]
// [[Rcpp::export(name=".mrwr_cpp")]]
Eigen::VectorXd mrwr_(const Eigen::VectorXd& p0,
                      const Eigen::MatrixXd& W,
                      const double r)
{
  // impl
}

In this example // [[Rcpp::interfaces(r, cpp)]] would create a header file with the name of my R package (lets say the package is called diffusr). The content of the exported header (diffusr.h) would look like this:

// This file was generated by Rcpp::compileAttributes
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#ifndef __diffusr_h__
#define __diffusr_h__

#include "diffusr_RcppExports.h"

#endif // __diffusr_h__

Is there a way to change the header include guard autamatically? Two leading "_" might lead to undefined behaviour, if I am correct, and is reserved for the standard library (What are the rules about using an underscore in a C++ identifier?)

Best, Simon

Community
  • 1
  • 1

1 Answers1

2

Briefly:

  • "You don't", as that is done in the code generators within Rcpp, so you would have to change Rcpp

  • Check the master branch on GitHub corresponding to the next release (in a week or two) as this was recently changed

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725