Input sting for wrapped C++ function doesn't changing

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Input sting for wrapped C++ function doesn't changing

galaxyblazer
This post has NOT been accepted by the mailing list yet.
I make Python wrapper for C++ library.

mylib.i:

%module mylib
%include <std_string.i>
%{
    #include "mylib.h"

%}
%apply const std::string & {std::string &};

int getResult(const std::string& path, std::string& result);

mylib.h:

#pragma once

#include <string>

myEnum {foo=0, bar};
myEnum getResult(const std::string& path, std::string& result);

///////
After generating _mylib.so with following command:
g++ -fPIC -Wall -Wextra -shared mylib_wrap.cxx -o _mylib.so -L. -lmylib -I/usr/include/python2.7/ -lpython2.7

I do next:

LD_LIBRARY_PATH=. python Python 2.7.2 (default, Dec  6 2016, 10:43:39)
[GCC 4.8.4] on linux4
Type "help", "copyright", "credits" or "license" for more information.
>>> import _mylib
>>> result= ""
>>> x = _mylib.getResult("somePath",result)

When I try print result, I have empty string. The most strange thing for me in this situation, that function sent right output to console, so I'm sure that function execute normally.