string arguments are not recognized by SWIG

前提是你 提交于 2019-12-30 05:08:12

问题


I have a frustrating problem which got me spend a lot of time dealing with it but I did not find any solution.

I want to use C++ class in PHP with SWIG. I generated my shared object and it works fine for some methods but I've got this error whenever I call the methods with string arguments as their input:

Fatal error: Type error in argument 2 of PKI_Buf_initHex. Expected SWIGTYPE_p_std__string

PKI_Buf_initHex is the name of the wrapper class which SWIG made automatically. In my C++ code I declare initHex method as:

int initHex(const string x) 
{..}

I included typemaps.i and std_string.i in my interface file but I got the same error message.

I truly would appreciate if anyone can help me with this issue.


回答1:


You need to have:

%include <std_string.i>

Early enough in the SWIG interface (i.e. before std::string is first seen).



来源:https://stackoverflow.com/questions/12236150/string-arguments-are-not-recognized-by-swig

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!