Skip to content

Instantly share code, notes, and snippets.

@hacst
Created July 15, 2015 21:34
Show Gist options
  • Save hacst/f1728593df0c7b23e29d to your computer and use it in GitHub Desktop.
Save hacst/f1728593df0c7b23e29d to your computer and use it in GitHub Desktop.
Basic test case for SWIG code generation producing valid code not accepted by MSVC
%module EnumClassGenerationIssue
%include <std_vector.i>
%inline {
enum class TestEnum {};
}
%template(TestEnumVector) std::vector<TestEnum>;
@hacst
Copy link
Author

hacst commented Jul 15, 2015

When building a wrapper for say java from this with SWIG 3.0.6 generates snippets like:

std::vector< enum TestEnum >::value_type temp2 ;

Which trigger:

error C3431: 'TestEnum' : a scoped enumeration cannot be redeclared as an unscoped enumeration

In MSVC. This has been reported as a bug against MSVC multiple times but doesn't seem to be something they want to fix:
https://connect.microsoft.com/VisualStudio/feedback/details/781517/enum-class-example-from-c-11-standard-produces-compilation-error
https://connect.microsoft.com/VisualStudio/feedback/details/771978/compiler-error-c3431-using-elaborated-type-specifiers-for-scoped-enumerations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment