8

I am having some trouble when trying to use the RcppEigenpackage. I used the example posted here. The function worked, but R generated a series of similar warnings (example as below).

In file included from example.cpp:1:
In file included from /Users/nguy2338/Library/R/3.4/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Users/nguy2338/Library/R/3.4/library/RcppEigen/include/RcppEigenForward.h:30:
In file included from /Users/nguy2338/Library/R/3.4/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Users/nguy2338/Library/R/3.4/library/RcppEigen/include/Eigen/Core:531:
/Users/nguy2338/Library/R/3.4/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma clang diagnostic pop

So, what do these warnings mean and how should I deal with these warnings?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Hoang Nguyen
  • 81
  • 1
  • 2
  • I think this is actually harmless, but you might need to talk to RcppEigen and/or Eigen maintainers to find out? – Ben Bolker Mar 28 '18 at 03:42
  • see also: http://discourse.mc-stan.org/t/boost-and-rcppeigen-warnings-for-r-package-using-stan/3478/2 ; http://dirk.eddelbuettel.com/blog/2018/02/13/#bh_1.66.0-1 – Ben Bolker Mar 28 '18 at 03:45
  • 5
    You can suppress these warnings _locally_ by adding to `~/.R/Makevars` on your machine (and I often do as warnings are annoying); per the wisdom of the CRAN maintainers and their Policy you cannot suppress them at CRAN :-/ – Dirk Eddelbuettel Mar 28 '18 at 13:06
  • I added `PKG_CPPFLAGS = -Wno-unknown-pragmas` to my `Makevars` but I still see these warnings: am I missing something? – daknowles Mar 28 '19 at 19:43

2 Answers2

3

The solution is

#define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
#include <Eigen/Eigen>
THK
  • 486
  • 3
  • 11
-1

I wonder if there is inadvertently some code commented out here: https://github.com/RcppCore/RcppEigen/blob/master/inst/include/Eigen/src/Core/util/DisableStupidWarnings.h#L41

which accounts for the mismatched pop here: https://github.com/RcppCore/RcppEigen/blob/master/inst/include/Eigen/src/Core/util/ReenableStupidWarnings.h#L13

The real warning it is trying to enable is -Wconstant-logical-operand which may be annoying, but not as annoying as this missing push.