Skip to content

Commit

Permalink
COMP: include stdlib.h for SWIG free/malloc with the Stable ABI
Browse files Browse the repository at this point in the history
Needed by SWIG for free/malloc, but not included by Python.h with recent versions of the Stable ABI

Addresses:

  C:\P\IPP\ITK-win_311-x64\Wrapping\Modules\ITKIOImageBase\itkImageSeriesWriterPython.cpp(1416): error C3861: 'free': identifier not found
  C:\P\IPP\ITK-win_311-x64\Wrapping\Modules\ITKIOImageBase\itkImageSeriesWriterPython.cpp(1562): error C3861: 'malloc': identifier not found

Fix for upstream submitted: swig/swig#2856
  • Loading branch information
thewtex committed Apr 3, 2024
1 parent d55b260 commit 7e4c0c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Wrapping/Generators/Python/PyBase/pyBase.i
@@ -1,5 +1,10 @@
%module(package="itk") pyBasePython

%insert("begin") %{
// Needed by SWIG for free/malloc, but not included by Python.h with recent versions of the Stable ABI
#include "stdlib.h"
%}

%pythonbegin %{
from . import _ITKPyBasePython
import collections
Expand Down
5 changes: 5 additions & 0 deletions Wrapping/Generators/Python/main_module_ext.i.in
Expand Up @@ -4,6 +4,11 @@
@ITK_WRAP_PYTHON_GLOBAL_TIMESTAMP_DECLS@
%}

%insert("begin") %{
// Needed by SWIG for free/malloc, but not included by Python.h with recent versions of the Stable ABI
#include "stdlib.h"
%}

%pythoncode %{
swig = {}
@ITK_WRAP_PYTHON_LIBRARY_IMPORTS@
Expand Down
5 changes: 5 additions & 0 deletions Wrapping/Generators/Python/module_ext.i.in
Expand Up @@ -8,4 +8,9 @@
#define SWIGPY_SLICEOBJECT PyObject
%}

%insert("begin") %{
// Needed by SWIG for free/malloc, but not included by Python.h with recent versions of the Stable ABI
#include "stdlib.h"
%}

@ITK_WRAP_PYTHON_SWIG_EXT@

0 comments on commit 7e4c0c5

Please sign in to comment.