2011-05-22 31 views
1

我是C++和SWIG的新手。這是我的第一個項目。Swig,Python,C++:TypeError:方法'Geodatabase_Open',參數2類型'std :: string'

我能夠使用distutils成功構建我的Python擴展。但是,當我嘗試我的對象時,我不斷收到此錯誤。

似乎有一個轉換問題從獲取python字符串並將其轉換爲std :: string。

我的工作在Windows 7中,使用Visual Studio C++ 2008速成

這是我痛飲接口文件

/* 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(); 
    }; 
} 

回答

4

按照swig documentation,使用std::string需要%include "std_string.i"

%module example 
%include "std_string.i" 

std::string foo(); 
void  bar(const std::string &x); 
相關問題