0

The C++ code in my package has using namespace Eigen; but this doesn't get put at the top of the auto-generated RcppExports.cpp. As a result compilation fails complaining MatrixXd etc is not recognized. I can manually add using namespace Eigen; to RcppExports.cpp and everything works fine, but this make the workflow pretty painful.

Is there some way to configure Rcpp to automatically add using namespace Eigen; to RcppExports.cpp?

daknowles
  • 1,426
  • 15
  • 19
  • 4
    For interfaces like function signatures I recommend to fully qualify and use _e.g._ `Eigen::MatrixXd`. Look what other packages do. Also, see the Rcpp Attributes vignette about the `mypackage_types.h` header (where `mypackage` gets replaced with your package name). – Dirk Eddelbuettel Mar 28 '19 at 17:50
  • Thanks Dirk, `mypackage_types.h` is exactly what I want. – daknowles Mar 28 '19 at 19:49
  • 1
    Also, note that in general, `using namespace foo` can lead to headaches down the road. See [c++- Why is "using namespace std" considered bad practice?](https://stackoverflow.com/q/1452721/4408538) – Joseph Wood Mar 29 '19 at 13:41

0 Answers0