0

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?

Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
Giacomo
  • 412
  • 3
  • 10

1 Answers1

2

Try this:

%Module ieproxy 0  

%UnitCode
#include <ProxySettings.h>
%End

bool SetConnectionOptions(const char * proxy_full_addr); 
bool DisableConnectionProxy(); 
Magnus
  • 546
  • 3
  • 10
  • This solution is not working for me inline`mingw32-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>python Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32 >>> import learn Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: The specified module could not be found.` – Ravi Yadav Apr 25 '16 at 11:33