stan-dev / stan-dev/rstantools
Conflict with RcppArmadillo and Rcpp when exporting `.stanfunctions`
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 48
- Forks
- 24
- Avg merge
- 1h 17m
- Merged PRs (30d)
- 1
Description
Sorry that I don't have a minimal example at the moment, but I can create one if needed.
I'm trying to export some Stan functions to R in a package which also includes C++ code using RcppArmadillo. I have a file Rexports.stanfunctions in inst/stan, but when installing the package I get an error "The file 'Rcpp.h' should not be included. Please correct to include only 'RcppArmadillo.h'.". This seems to be due to the incorrect order of including RcppArmadillo and Rcpp headers because in the autogenerated RcppExports.cpp file<packagename>_types.h is included first (such file is not created when there are no Stan functions to be exported):
#include "packagename_types.h"
#include <RcppArmadillo.h>
#include <RcppEigen.h>
#include <Rcpp.h>
The first include contains exporter.h from Rcpp which seems to mess things. Moving the first line to last after other includes seems to get rid of the error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with inst/stan/Rexports.stanfunctions and the generated RcppExports.cpp, then inspect how _types.h and the RcppArmadillo, RcppEigen, and Rcpp headers are included. Reproduce the package installation and verify that the generated package builds without the Rcpp.h include-order error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, r
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100