Python SIP expose function

别说谁变了你拦得住时间么 提交于 2019-12-11 23:41:43

问题


I'm writing a Python module for some C++ code using SIP. However whilst I can easily expose classes, I cannot find a way to expose standalone functions.

Here is my header file defining the functions that I wish to expose to Python: ProxySettings.h

#include <Windows.h>
#include <Wininet.h>

bool SetConnectionOptions(const char * proxy_full_addr);
bool DisableConnectionProxy();

And here is my attempt at my SIP file so far: ProxySettings.sip. Currently running sip.exe generates C++ code with no problems, but when I come to compile it, the compiler complains about missing identifiers SetConnectionOptions and DisableConnectionProxy.

%Module ieproxy 0

bool SetConnectionOptions(const char * proxy_full_addr);
bool DisableConnectionProxy();

I think that I have to use a directive to include the ProxySettings.h header file into my SIP file, but I am not sure what directive to use. %TypeHeaderCode which is what you use for a class doesn't work with just a function.

Does anyone have any suggestions?


回答1:


Try this:

%Module ieproxy 0  

%UnitCode
#include <ProxySettings.h>
%End

bool SetConnectionOptions(const char * proxy_full_addr); 
bool DisableConnectionProxy(); 


来源:https://stackoverflow.com/questions/5614979/python-sip-expose-function

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