#758 fails to resolve typedefs defined in classes

closed-out-of-date
5
2009-11-14
2006-10-22
No

If I have a typedef in a class definition, for instance:

class MyTestClass {
public:
typedef int MyIntegerType;
MyIntegerType f(MyIntegerType x);
}

then SWIG will fail to resolve objects of type
MyIntegerType to int's. It will generate an entry in
the types table of the generated wrapper code, and the
function f is unusable because the user of the bound
code can't generate an object that SWIG will recognise
as being of type MyIntegerType, and wouldn't be able to
do anything with the returned opaque value anyway.

Making the typedef private (or protected) rather than
public will stop SWIG making an entry in the types
table, but it will still declare temporary objects of
type MyTestClass::MyIntegerType in the wrapper for f,
so the wrapper will now fail to compile. It behaves
like this even if you give it an explicit

%apply int {MyTestClass::MyIntegerType}

This is a particularly bad bug if your code uses this
language feature because there doesn't seem to be a way
to work around it.

I don't think this is a language-specific problem, but
just for reference: I am generating bindings for Perl 5
and C#. I am using the SWIG 1.3.29 packaged with Debian
on AMD64, and I'm happy to help debug or build from CVS
if that will help.

Discussion

  • William Fulton

    William Fulton - 2009-11-14

    This is currently working with swig-1.3.40, tested with c# and perl.

     
  • William Fulton

    William Fulton - 2009-11-14
    • assigned_to: beazley --> wsfulton
    • status: open --> closed-out-of-date
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks