You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create template from std::vector %template(ColorList) std::vector<Color> but SWIG binary crashes with Segmentation fault: 11
I think it crashes due to that that implementation of my header with Color struct looks like that:
extern "C" {
typedef struct Color Color;
struct Color {
int red;
int green;
int blue;
};
}
The problem is in typedef struct Color Color; probably there is some name conflict, cuz when I comment it out, it works fine.
But for few reasons I need to it stay like this.
When I comment out creating a template with type Color it also works fine, so this typedef is only problematic during template creation.
Is this crash known? Or is there any trick that can I use in swig's interface files to avoid this crash ?
The text was updated successfully, but these errors were encountered:
%module x
%include std_vector.i
%inline %{
#include <vector>
extern "C" {
typedef struct Color Color;
struct Color {
int red;
int green;
int blue;
};
}
%}
%template(ColorList) std::vector<Color>;
Process with swig -c++ -python test.i
gdb shows Swig_symbol_typedef_reduce calling itself over and over at Swig/symbol.c:1905 (using the commit 44990e2). It looks like the parameters are the same every time, so we could check for that and catch this case, but that's not very useful without knowing how to handle it.
I thought there was an existing report of a similar case and found https://sourceforge.net/p/swig/bugs/140/ in the old tracker, but that was fixed long ago and is probably significantly different (the equivalent in the case here would be a typedef of ColorList rather than Color).
I'm trying to create template from std::vector
%template(ColorList) std::vector<Color>
but SWIG binary crashes withSegmentation fault: 11
I think it crashes due to that that implementation of my header with
Color
struct looks like that:The problem is in
typedef struct Color Color;
probably there is some name conflict, cuz when I comment it out, it works fine.But for few reasons I need to it stay like this.
When I comment out creating a template with type
Color
it also works fine, so thistypedef
is only problematic during template creation.Is this crash known? Or is there any trick that can I use in swig's interface files to avoid this crash ?
The text was updated successfully, but these errors were encountered: