Open ojwb opened 7 months ago
-debug-typedef
for the first example above says:
SCOPES start =======================================
-------------------------------------------------------------
Type scope '' (0x7f815ce00b10)
baz -> enum baz
-------------------------------------------------------------
Type scope 'swig::SwigVar_PyObject' (0x7f815cf4bf70)
-------------------------------------------------------------
Type scope 'swig::SwigPtr_PyObject' (0x7f815cf4bd10)
-------------------------------------------------------------
Type scope 'swig' (0x7f815cf4ba30)
SwigPtr_PyObject -> SwigPtr_PyObject
SwigVar_PyObject -> SwigVar_PyObject
-------------------------------------------------------------
Type scope 'std' (0x7f815cf4b950)
initializer_list -> initializer_list
SCOPES finish =======================================
can also happen with pointer (#3120):
%module example
%inline %{
typedef enum {E1, E2} enum_type1;
void foo(const enum_type1 **const bar);
%}
This has been reported multiple times over the years, often conflated with related but separate issues with a superficially similar qualifying problem with C++11
enum class
. Opening one issue to bring all these together in one place (and because I think I've fixed the other issue so those other issues will be closed soon).Seems to be in generic code as it affects most (probably all) target languages.
https://sourceforge.net/p/swig/bugs/682/
Reproducer:
Then:
The
const &
seems to be needed.I notice the type info entry includes
enum baz *
which seems wrong too.https://sourceforge.net/p/swig/bugs/923/
Reproducer:
197
The original report is a different issue with C++11
class enum
, but the second example there a typedef to an anonymous enum.Reproducer:
The problem here is that SWIG generates
enum s
buts
is atypedef
to anenum
, not anenum
itself, and GCC gives an error: