So I'm trying to create a C extension and am having a bit of trouble accessing the struct data for one of my arguments. Here's my current code:
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct Point {
int x;
int y;
} Point;
static PyObject *test(PyObject *self, PyObject *args) {
Point *start, *end = NULL;
if(!PyArg_ParseTuple(args, "OO", &start, &end)) {
return NULL;
}
printf("%d %d\n", (int)start->x, (int)start->y);
printf("%d %d\n", (int)end->x, (int)end->y);
return PyLong_FromLong(0);
}
Python code which calls it:
import testmodule
testmodule.test((5, 4), (7, 1))
I'm trying to get these inputs tuples to be converted into Point structs so they can be used further on in the program. Any idea how I can fix this?
Any help would be appreciated.
"ii"instead of"OO"to get integers.(5, 4)and(7, 1)be created as structs though?Pointstructs.