From e69b79e872d112c9bebf78c816c515ecd0d80964 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Tue, 26 Nov 2019 15:10:19 +0100 Subject: [PATCH] Fix import_array() call when exporting numpy functionality import_array() must be called when the numpy C-API is called. This is a macro that in our case defined a return value that makes the compiler complain. The added #define statement enforces no return value --- modules/gfx/pymod/export_primlist.cc | 2 ++ modules/mol/base/pymod/export_editors.cc | 2 ++ modules/mol/base/pymod/export_entity.cc | 2 ++ 3 files changed, 6 insertions(+) diff --git a/modules/gfx/pymod/export_primlist.cc b/modules/gfx/pymod/export_primlist.cc index d11d74656..ba586fe62 100644 --- a/modules/gfx/pymod/export_primlist.cc +++ b/modules/gfx/pymod/export_primlist.cc @@ -137,6 +137,8 @@ namespace { void export_primlist() { #if OST_NUMPY_SUPPORT_ENABLED + // The following define enforces no return value when calling import_array + #define NUMPY_IMPORT_ARRAY_RETVAL import_array(); // magic handshake for numpy module #endif diff --git a/modules/mol/base/pymod/export_editors.cc b/modules/mol/base/pymod/export_editors.cc index 4bb64bd8a..50aa16842 100644 --- a/modules/mol/base/pymod/export_editors.cc +++ b/modules/mol/base/pymod/export_editors.cc @@ -227,6 +227,8 @@ void set_t_pos(XCSEditor& e, object o1, object o2) void export_Editors() { #if OST_NUMPY_SUPPORT_ENABLED + // The following define enforces no return value when calling import_array + #define NUMPY_IMPORT_ARRAY_RETVAL import_array(); #endif diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc index 538921e2b..35b918b16 100644 --- a/modules/mol/base/pymod/export_entity.cc +++ b/modules/mol/base/pymod/export_entity.cc @@ -130,6 +130,8 @@ bool depr_is_transformation_identity(const EntityHandle& eh) void export_Entity() { #if OST_NUMPY_SUPPORT_ENABLED + // The following define enforces no return value when calling import_array + #define NUMPY_IMPORT_ARRAY_RETVAL import_array(); #endif -- GitLab