Swig unable to convert byte objectof python3 to std::string

I am trying to interface python3 with C++ using SWIG and it keeps throwing the following error
>> ipc.sendMessage(q, b'qwe')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: in method 'sendMessage', argument 2 of type 'std::string'**
Below are the attached files:
ipc.i file
%module ipc

%begin %{
    #define SWIG_PYTHON_STRICT_BYTE_CHAR
    #include "ipc.h"   
%}

%include std_string.i
%include stl.i
%include "ipc.h"
ipc.h file
#include<string>

extern int createQueue();
extern bool sendMessage(int, std::string);
extern std::string receiveMessage(int);
extern bool removeQueue(int);
Command used to build
>> swig -c++ -python ipc.i
>> g++ -fpic -c ipc.h ipc_wrap.cxx ipc.cpp -I/usr/include/python3.5
>> gcc -shared ipc_wrap.o ipc.o -o _ipc.so -lstdc++

Комментарии

Популярные сообщения из этого блога

Unable to construct Application instance [duplicate]

What is considered 'insulting a Muslim'? And is it a sin? If so, is it a minor or major scene?