【问题标题】:Python SIP expose functionPython SIP 暴露函数
【发布时间】:2011-04-10 21:50:57
【问题描述】:

我正在使用 SIP 为一些 C++ 代码编写 Python 模块。然而,虽然我可以轻松地公开类,但我找不到公开独立函数的方法。

这是我的头文件,它定义了我希望向 Python 公开的函数:ProxySettings.h

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

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

到目前为止,这是我对 SIP 文件的尝试:ProxySettings.sip。当前运行 sip.exe 生成 C++ 代码没有问题,但是当我来编译它时,编译器抱怨缺少标识符 SetConnectionOptionsDisableConnectionProxy .

%Module ieproxy 0

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

我认为我必须使用指令将 ProxySettings.h 头文件包含到我的 SIP 文件中,但我不确定要使用什么指令。用于类的 %TypeHeaderCode 不能仅用于函数。

有人有什么建议吗?

【问题讨论】:

    标签: c++ python python-sip


    【解决方案1】:

    试试这个:

    %Module ieproxy 0  
    
    %UnitCode
    #include <ProxySettings.h>
    %End
    
    bool SetConnectionOptions(const char * proxy_full_addr); 
    bool DisableConnectionProxy(); 
    

    【讨论】:

    • 此解决方案不适用于我 inlinemingw32-make install makefile:26: warning: ignoring old recipe for target '.c.o' copy /y learn.pyd C:\Python35-32\Lib\site-packages\learn.pyd 1 file(s) copied. strip C:\Python35-32\Lib\site-packages\learn.pyd learn&gt;python Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32 &gt;&gt;&gt; import learn Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: DLL load failed: The specified module could not be found.
    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 2010-12-05
    • 2018-08-08
    相关资源
    最近更新 更多