Search code examples
c++pythonpython-sip

Python SIP expose function


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?


Solution

  • Try this:

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