2

On compilation I am getting lots of warnings that I would love to resolve. There are 30 or so but they all more or less look like these first three:


==> Rcpp::compileAttributes()
* Updated src/RcppExports.cpp

==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))

Creating a generic function for ‘as.list’ from package ‘base’ in package ‘roxygen_devtest’
Documentation completed

==> R CMD INSTALL --no-multiarch --with-keep.source myPackage

* installing to library ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library’
* installing *source* package ‘myPackage’ ...
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/BH/include"   -fPIC  -Wall -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
** libs
RcppExports.cpp:14:1: warning: unused variable 'rcpp_output_type' [-Wunused-variable]
BEGIN_RCPP
^

/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/Rcpp/macros/macros.h:31:9: note: expanded from macro 'BEGIN_RCPP'
int rcpp_output_type = 0 ;                                                                   \
    ^
RcppExports.cpp:14:1: warning: unused variable 'rcpp_output_condition' [-Wunused-variable]
/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/Rcpp/macros/macros.h:32:10: note: expanded from macro 'BEGIN_RCPP'
SEXP rcpp_output_condition = R_NilValue ;                                                    \
     ^
RcppExports.cpp:49:1: warning: unused variable 'rcpp_output_type' [-Wunused-variable]
BEGIN_RCPP
^
/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/Rcpp/macros/macros.h:31:9: note: expanded from macro 'BEGIN_RCPP'
int rcpp_output_type = 0 ;                                                                   \
    ^
RcppExports.cpp:49:1: warning: unused variable 'rcpp_output_condition' [-Wunused-variable]
/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include/Rcpp/macros/macros.h:32:10: note: expanded from macro 'BEGIN_RCPP'
SEXP rcpp_output_condition = R_NilValue ;                                                    \
     ^

If anyone can point me in the right direction I would appreciate it. If more of the output is needed I can provide it, I just wanted to keep the message as short as possible.

  • It is generally quite important to distinguish between a warning and an error. While, as a general rule, developers should strive for warning-free compilation using the "-Wall" compiler flag, this is often not possible without disproportionate effort, especially in cross-platform environments which may include different installations. To put this more shortly: It is good to notice and remember compiler warnings if some unexpected behavior occurs when a program runs, but in most cases they can safely be ignored. – RHertel May 15 '16 at 08:37

1 Answers1

4

I just add this to CXXFLAGS in the file ~/.R/Makevars:

CXXFLAGS +=           -O3 -Wall -pipe -Wno-unused 
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Know any way to suppress the warnings for a specific file? I don't see this in clang or gcc flags, other than using `#pragma GCC diagnostic ignored "-Wall"` which, AFAIK, can't be inserted by us into the generated RcppExports.cpp code. – Jack Wasey Sep 13 '16 at 11:20
  • 1
    Sorry, I do not, hence my use of `CXXFLAGS` and `CXX1XFLAGS`. – Dirk Eddelbuettel Sep 13 '16 at 11:34