Static (why?) PyDateTimeAPI and SIP

D

Denis S. Otkidach

I use datetime C API in extension module generated with SIP. But SIP
break the code into several .cpp files compiled separately and
PyDateTimeAPI used by all macros constituting public interface is
declared static.

The current solution is to define my own functions in main module as
workaround:

%ModuleHeaderCode
PyObject * mxo_PyDateTime_FromDateAndTime(int year, int month, int day,
int hour, int minute, int seconds,
int usecs);
%End

%ModuleCode
PyObject * mxo_PyDateTime_FromDateAndTime(int year, int month, int day,
int hour, int minute, int seconds,
int usecs) {
return PyDateTime_FromDateAndTime(year, month, day, hour, minute, seconds,
usecs);
}
// and so on for each macro used
%End

%PostInitialisationCode
PyDateTime_IMPORT;
%End

But I wonder why PyDateTimeAPI is declared static, and is the a better
solution?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,252
Messages
2,571,267
Members
47,908
Latest member
MagdalenaR

Latest Threads

Top