Python PyObject_AsReadBuffer移植问题
正如我们所知,PyObject_AsReadBuffer在版本2.5中发生了更改 在v2.4上,我们可以这样使用它Python PyObject_AsReadBuffer移植问题,python,c,porting,Python,C,Porting,正如我们所知,PyObject_AsReadBuffer在版本2.5中发生了更改 在v2.4上,我们可以这样使用它 int bufferLength = 0; const void* buffer = NULL; PyObject_AsReadBuffer(pyObj, &buffer, &buffer_len); 但我必须这样修改它才能在v2.7上运行 Py_ssize_t bufferLength = 0; const void* buffer = NULL; PyObj
int bufferLength = 0;
const void* buffer = NULL;
PyObject_AsReadBuffer(pyObj, &buffer, &buffer_len);
但我必须这样修改它才能在v2.7上运行
Py_ssize_t bufferLength = 0;
const void* buffer = NULL;
PyObject_AsReadBuffer(pyObj, &buffer, &buffer_len);
如果我想在v2.4和v2.7上运行它,我应该怎么做?在include/python2.7/patchlevel.h中
#define PY_MAJOR_VERSION 2
#define PY_MINOR_VERSION 7
因此,我们可以使用PY_MAJOR_版本PY_MINOR_版本来比较版本