-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWIG %template directives are incorrectly scoped #768
Comments
I removed the |
This problem is silently ignored in versions of SWIG before 4.0, in which it becomes an error. So we have until that becomes the default version to convert |
I tested this example with Ubuntu 20.04 with SWIG 4.0. I got different code in the .i file and it compiled successfully.
|
I added some logic in e6509df to put the |
e6509df worked well enough until SWIG 4.2.0, which requires that a
#1679, #1696, and #1741 got things partially working again, but there are still several problems. All of the below is valid C++ code, but template <class T>
class Foo {};
namespace peer {
template <class T>
class Bar {};
}
namespace prime {
template<class T>
class Potato {};
namespace nested {
template <class T>
class Baz {};
}
class Onion {
public:
template<class T>
class InnerOnion {}; // onions have layers!
/**
* Error: 'Foo' resolves to '::Foo' and was incorrectly
* instantiated in scope 'prime' instead of within scope ''.
*/
//Foo<int> foo1;
::Foo<int> foo2;
peer::Bar<int> bar1;
::peer::Bar<int> bar2;
/**
* error: ‘Potato’ was not declared in this scope;
* did you mean ‘prime::Potato’?
*/
// Potato<int> potato1;
prime::Potato<int> potato2;
::prime::Potato<int> potato3;
// Error: Undefined scope 'nested'
// nested::Baz<int> baz1;
prime::nested::Baz<int> baz2;
::prime::nested::Baz<int> baz3;
// Error: Template 'InnerOnion' undefined.
// InnerOnion<int> layer1;
// Error: Undefined scope 'Onion'
// Error: Template 'Onion::InnerOnion' undefined.
// Onion::InnerOnion<int> layer2;
// Error: Undefined scope 'prime::Onion'
// Error: Template 'prime::Onion::InnerOnion' undefined.
//prime::Onion::InnerOnion<int> layer3;
// Error: Undefined scope 'prime::Onion'
// Error: Template '::prime::Onion::InnerOnion' undefined.
//::prime::Onion::InnerOnion<int> layer4;
};
} |
convert_swig
writes a%template
directive for each instantiation of a template it finds.The above header file produces a section in the corresponding
.i
file:According to the SWIG 4.0 documentation:
The above example results in the following:
The text was updated successfully, but these errors were encountered: