Skip to content

Commit 9edb78e

Browse files
committed
fix test on pybind version
1 parent 8f56b56 commit 9edb78e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Plugin/src/SofaPython3/config.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@
3939
#define SOFAPYTHON3_API SOFA_IMPORT_DYNAMIC_LIBRARY
4040
#endif
4141

42+
// define own pybind version macro, much easier to test/read
43+
#define PYBIND11_SOFA_VERSION (PYBIND11_VERSION_MAJOR * 10000 \
44+
+ PYBIND11_VERSION_MINOR * 100 \
45+
+ PYBIND11_VERSION_PATCH)
4246
// pybind11 already bind the attributeError starting from 2.8.1 version.
4347
// so if the version is >= 2.8.1, macro does nothing, otherwise bind attribute_error
44-
#if not(PYBIND11_VERSION_MAJOR >= 2 && PYBIND11_VERSION_MINOR >= 8 && PYBIND11_VERSION_PATCH >= 1)
45-
#define SOFAPYTHON3_BIND_ATTRIBUTE_ERROR() namespace pybind11 { PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError) }
46-
#else
48+
#if PYBIND11_SOFA_VERSION >= 20801
4749
#define SOFAPYTHON3_BIND_ATTRIBUTE_ERROR()
48-
#endif // not(PYBIND11_VERSION >= 2.8.1)
50+
#else
51+
#define SOFAPYTHON3_BIND_ATTRIBUTE_ERROR() namespace pybind11 { PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError) }
52+
#endif // PYBIND11_SOFA_VERSION >= 20801

0 commit comments

Comments
 (0)