Hugo Estrada
Hugo Estrada

Reputation: 627

Swig, Python, C++: TypeError: in method 'Geodatabase_Open', argument 2 of type 'std::string'

I am new to C++ and SWIG. This is my first project.

I am able to successfully build my Python extension using distutils. However, when I try my object, I keep getting this error.

It seems that there is a conversion problem from getting the python string and transforming it into a std::string.

I am working on Windows 7, using Visual Studio C++ 2008 Express

Here is my swig interface file

/* swig interface file */
%module Geodatabase 
%{
#include Geodatabase_helper.h
%}
namespace FileGeodatabase {
  class Geodatabase {
    public:
  Geodatabase();
  Geodatabase(std::string p);
  ~Geodatabase();
  void Open(std::string p);
  void Close();
   };
}

Upvotes: 1

Views: 3042

Answers (1)

Robᵩ
Robᵩ

Reputation: 168886

According to the swig documentation, using std::string requires %include "std_string.i".

%module example
%include "std_string.i"

std::string foo();
void        bar(const std::string &x);

Upvotes: 4

Related Questions