Skip to content

Conflict with RcppArmadillo and Rcpp when exporting .stanfunctions #127

Description

@helske

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions