Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1227 namespace/using breaks shared_ptr typemap

open
nobody
python (259)
5
2012-12-21
2012-03-06
Anonymous
No

if the 'using std::tr1::shared_ptr;' statement is itself nested in a local namespace, then the shared_ptr typemap breaks down. A small isolated version of the problem has been included in a tarball. Please see the code there for more details.

This appears to be a rather odd corner case. However, I managed to spend days confounded by it none the less. I didn't find a solution for my project until after reading the boost_shared_ptr.i file.

The offending output when g++ is run on the generated wrapper code is as follows:
example_wrap.cxx: In function ‘PyObject* _wrap_MyObject_create(PyObject*, PyObject*)’:
example_wrap.cxx:3061: error: ‘shared_ptr’ was not declared in this scope
example_wrap.cxx:3061: error: template argument 1 is invalid
example_wrap.cxx:3061: error: expected unqualified-id before ‘>’ token
example_wrap.cxx:3064: error: ‘result’ was not declared in this scope
example_wrap.cxx:3065: error: expected type-specifier before ‘shared_ptr’
example_wrap.cxx:3065: error: expected `)' before ‘shared_ptr’
example_wrap.cxx:3065: error: expected `)' before ‘;’ token

Discussion

  • David Froger
    David Froger
    2012-03-23

    Hi,

    Adding "using namespace myName;" beetween %{ %} make the example in tarball works, that is:

    %{
    #include "example.h"
    using namespace myName;
    %}

    Best,
    David

     
  • William Fulton
    William Fulton
    2012-06-30

    Seems to be related to #3520002