title: SWIG wrapper undeclared (first use in this function)
body: <p>I am trying to create a wrapper for C++ code to use it in a python project.
  The code is taken from <a href="https://github.com/erdavila/M-Tree/tree/master/cpp" rel="nofollow noreferrer">here</a> (mainly <code>mtree.h</code>).</p>
  
  <p>I am using swig for generating the interface by:
  <code>swig -python -module mtree mtree.h</code></p>
  
  <p>then when I try <code>gcc -c -fpic mtree_wrap.c</code> I get the following error:</p>
  
  <pre><code>user@ubuntu:~/git/M-Tree/cpp2python(master)$ gcc -c -fpic mtree_wrap.c
  mtree_wrap.c: In function ‘Swig_var_mt_set’:
  mtree_wrap.c:3029:7: error: ‘mt’ undeclared (first use in this function)
         mt = *((namespace *)(argp));
         ^~
  mtree_wrap.c:3029:7: note: each undeclared identifier is reported only once for each function it appears in
  mtree_wrap.c:3029:15: error: ‘namespace’ undeclared (first use in this function); did you mean ‘isspace’?
         mt = *((namespace *)(argp));
                 ^~~~~~~~~
                 isspace
  mtree_wrap.c:3029:26: error: expected expression before ‘)’ token
         mt = *((namespace *)(argp));
                            ^
  mtree_wrap.c: In function ‘Swig_var_mt_get’:
  mtree_wrap.c:3041:47: error: ‘mt’ undeclared (first use in this function)
     pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&amp;mt), SWIGTYPE_p_namespace,  0 );
                                                 ^
  mtree_wrap.c:1163:89: note: in definition of macro ‘SWIG_NewPointerObj’
   ointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
                                                                          ^~~
  mtree_wrap.c:3041:30: note: in expansion of macro ‘SWIG_as_voidptr’
     pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&amp;mt), SWIGTYPE_p_namespace,  0 );
                                ^~~~~~~~~~~~~~~
  </code></pre>
  
  <p>and this is the <code>mtree.c</code> lines where the error occurs</p>
  
  <pre><code>SWIGINTERN int Swig_var_mt_set(PyObject *_val) {
    {
      void *argp = 0;
      int res = SWIG_ConvertPtr(_val, &amp;argp, SWIGTYPE_p_namespace,  0 );
      if (!SWIG_IsOK(res)) {
        SWIG_exception_fail(SWIG_ArgError(res), "in variable '""mt""' of type '""namespace""'");
      }
      if (!argp) {
        SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""mt""' of type '""namespace""'");
      } else {
        mt = *((namespace *)(argp));
      }
    }
    return 0;
  fail:
    return 1;
  }
  
  
  SWIGINTERN PyObject *Swig_var_mt_get(void) {
    PyObject *pyobj = 0;
  
    pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(&amp;mt), SWIGTYPE_p_namespace,  0 );
    return pyobj;
  }
  
  </code></pre>
  
  <p>Any solutions?</p>