Skip to content

Commit c3067cc

Browse files
committed
Compatibility with -Wconversion, -Wdeprecated
1 parent b4516ab commit c3067cc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

include/pybind11/eigen.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@
1111

1212
#include "numpy.h"
1313

14+
#if defined(__GNUC__)
15+
// These suppressions are needed only for certain compilers and versions of Eigen, but:
16+
// * Maintaining narrowly defined ifdefs is very complicated/expensive.
17+
// * These suppressions are applied only to the Eigen headers anyway.
18+
# pragma GCC diagnostic push
19+
# pragma GCC diagnostic ignored "-Wconversion"
20+
#if __GNUC__ != 8
21+
# pragma GCC diagnostic ignored "-Wdeprecated-copy"
22+
# pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor"
23+
#endif
24+
#endif
25+
1426
#include <Eigen/Core>
1527
#include <Eigen/SparseCore>
1628

29+
#if defined(__GNUC__)
30+
# pragma GCC diagnostic pop
31+
#endif
32+
1733
// Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit
1834
// move constructors that break things. We could detect this an explicitly copy, but an extra copy
1935
// of matrices seems highly undesirable.
@@ -64,8 +80,16 @@ template <bool EigenRowMajor> struct EigenConformable {
6480
if (rstride < 0 || cstride < 0) {
6581
negativestrides = true;
6682
} else {
83+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ != 8
84+
// Suppressing warning originating from Eigen header.
85+
# pragma GCC diagnostic push
86+
# pragma GCC diagnostic ignored "-Wdeprecated-copy"
87+
#endif
6788
stride = {EigenRowMajor ? rstride : cstride /* outer stride */,
6889
EigenRowMajor ? cstride : rstride /* inner stride */ };
90+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ != 8
91+
# pragma GCC diagnostic pop
92+
#endif
6993
}
7094
}
7195
// Vector type:

0 commit comments

Comments
 (0)