[R-pkg-devel] compileAttributes() and 'using namespace' directives

Georgi Boshnakov georgi.boshnakov at manchester.ac.uk
Tue Dec 8 15:37:45 CET 2015


Hi,

With a collaborator we are working on a package which uses Rcpp and RcppArmadillo.   Our *.cpp files  start with something like

// [[Rcpp::depends(RcppArmadillo)]]

#include <iostream>
#include "RcppArmadillo.h"

using namespace arma;
using namespace std;
using namespace Rcpp;


Running compileAttributes()  generates an RcppExports.cpp which gives errors unless we manually  add 

using namespace arma;

when everything is fine. Is this outside the scope of the automatic facilities?  

compileAttributes()   puts the corresponding directive for the Rcpp namespace but even after reading every possible source I could not figure out how to make this happen for the "arma" namespace. 

The same problem appears when using devtools::test() which exits with an error if RcppExports.cpp is not generated by it but if I remove that file, my understanding is that devtools::test() calls compileAttributes()  with the effect of producing invalid file and with little indication for the users what has gone wrong, besides the message "Error: Command failed (1)".


Thanks,
Georgi

 
--
Dr Georgi Boshnakov               tel: (+44) (0)161 306 3684
School of Mathematics             fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester      email: Georgi.Boshnakov at manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK




More information about the R-package-devel mailing list