'RcppEigen package "#pragma clang diagnostic pop" warnings

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?



Solution 1:[1]

The solution is

#define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
#include <Eigen/Eigen>

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 THK
Solution 2 user18843448