Rcpp中的Wunused-variable错误

时间:2016-05-15 03:12:16

标签: r rcpp

编译时我收到很多警告,我很想解决。有大约30个但是它们或多或少看起来像前三个:

==> 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 ;                                                    \
     ^

如果有人能指出我正确的方向,我会很感激。如果需要更多的输出我可以提供它,我只是想让信息尽可能短。

1 个答案:

答案 0 :(得分:3)

我只是将其添加到文件CXXFLAGS中的~/.R/Makevars

CXXFLAGS +=           -O3 -Wall -pipe -Wno-unused